* 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,29 +78,31 @@ 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; ELKey:=Format(SKeyEventLog,[IDentification]);
Try Result:=RegCreateKeyExA(HKEY_LOCAL_MACHINE,
R.RootKey:=HKEY_LOCAL_MACHINE; PChar(ELKey),0,'',
ELKey:=Format(SKeyEventLog,[IDentification]); REG_OPTION_NON_VOLATILE,
Result:=R.OpenKey(ELKey,True); KEY_ALL_ACCESS,
If Result then SecurityAttributes,Handle,
try pdword(@Disposition))=ERROR_SUCCESS;
R.WriteInteger(SKeyCategoryCount,4); If Result then
R.WriteString(SKeyCategoryMessageFile,AFileName); begin
R.WriteString(SKeyEventMessageFile,AFileName); Value:=4;
R.WriteInteger(SKeyTypesSupported,7); Result:=Result and (RegSetValueExA(Handle,PChar(SKeyCategoryCount),0,REG_DWORD,@Value,sizeof(DWORD))=ERROR_SUCCESS);
except Value:=7;
Result:=False; Result:=Result and (RegSetValueExA(Handle,PChar(SKeyTypesSupported),0,REG_DWORD,@Value,sizeof(DWORD))=ERROR_SUCCESS);
end Result:=Result and (RegSetValueExA(Handle,PChar(SKeyCategoryMessageFile),0,REG_SZ,@AFileName[1],Length(AFileName))=ERROR_SUCCESS);
Finally Result:=Result and (RegSetValueExA(Handle,PChar(SKeyEventMessageFile),0,REG_SZ,@AFileName[1],Length(AFileName))=ERROR_SUCCESS);
R.Free; end;
end;
end; end;
function TEventLog.MapTypeToCategory(EventType: TEventType): Word; function TEventLog.MapTypeToCategory(EventType: TEventType): Word;