* removed registry unit dependency by using winapi instead

git-svn-id: trunk@6666 -
This commit is contained in:
peter 2007-02-26 17:04:06 +00:00
parent 01b2873bf0
commit 90c5a79e2d

View File

@ -13,7 +13,7 @@
**********************************************************************} **********************************************************************}
uses windows,registry; uses windows;
Function TEventLog.DefaultFileName : String; Function TEventLog.DefaultFileName : String;
@ -70,7 +70,7 @@ end;
Function TEventLog.RegisterMessageFile(AFileName : String) : Boolean; Function TEventLog.RegisterMessageFile(AFileName : String) : Boolean;
Const Const
SKeyEventLog = '\SYSTEM\CurrentControlSet\Services\EventLog\Application\%s'; SKeyEventLog = 'SYSTEM\CurrentControlSet\Services\EventLog\Application\%s';
SKeyCategoryCount = 'CategoryCount'; SKeyCategoryCount = 'CategoryCount';
SKeyEventMessageFile = 'EventMessageFile'; SKeyEventMessageFile = 'EventMessageFile';
SKeyCategoryMessageFile = 'CategoryMessageFile'; SKeyCategoryMessageFile = 'CategoryMessageFile';
@ -78,28 +78,30 @@ Const
Var Var
ELKey : String; ELKey : String;
R : TRegistry; Handle : HKey;
SecurityAttributes: Pointer; //LPSECURITY_ATTRIBUTES;
Value,
Disposition : Dword;
begin begin
SecurityAttributes:=nil;
CheckIdentification; CheckIdentification;
If AFileName='' then If AFileName='' then
AFileName:=ParamStr(0); AFileName:=ParamStr(0);
R:=TRegistry.Create;
Try
R.RootKey:=HKEY_LOCAL_MACHINE;
ELKey:=Format(SKeyEventLog,[IDentification]); ELKey:=Format(SKeyEventLog,[IDentification]);
Result:=R.OpenKey(ELKey,True); Result:=RegCreateKeyExA(HKEY_LOCAL_MACHINE,
PChar(ELKey),0,'',
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
SecurityAttributes,Handle,
pdword(@Disposition))=ERROR_SUCCESS;
If Result then If Result then
try begin
R.WriteInteger(SKeyCategoryCount,4); Value:=4;
R.WriteString(SKeyCategoryMessageFile,AFileName); Result:=Result and (RegSetValueExA(Handle,PChar(SKeyCategoryCount),0,REG_DWORD,@Value,sizeof(DWORD))=ERROR_SUCCESS);
R.WriteString(SKeyEventMessageFile,AFileName); Value:=7;
R.WriteInteger(SKeyTypesSupported,7); Result:=Result and (RegSetValueExA(Handle,PChar(SKeyTypesSupported),0,REG_DWORD,@Value,sizeof(DWORD))=ERROR_SUCCESS);
except Result:=Result and (RegSetValueExA(Handle,PChar(SKeyCategoryMessageFile),0,REG_SZ,@AFileName[1],Length(AFileName))=ERROR_SUCCESS);
Result:=False; Result:=Result and (RegSetValueExA(Handle,PChar(SKeyEventMessageFile),0,REG_SZ,@AFileName[1],Length(AFileName))=ERROR_SUCCESS);
end
Finally
R.Free;
end; end;
end; end;