主要是从网上一段VB程序转化而来,其实代码很简单,只不过之前不知道有OpenEventLog这类的API函数。
//====================清除事件记录=======by liswa=================
function KillEventLog(EventName:String):boolean;
var
HEvent:Hwnd;
begin
HEvent:=OpenEventLog(nil,pchar(EventName));
if HEvent=0 then
begin
Result:=false;
exit;
end;
if ClearEventLog(HEvent,nil) then
begin
Result:=false;
exit;
end;
result:=CloseEventLog(HEvent);
end;
procedure DelEventLog;
var
HEvent:hwnd;
begin
KillEventLog('Application');
KillEventLog('System');
KillEventLog('Security');
KillEventLog('SecEvent.Evt');
KillEventLog('SysEvent.Evt');
KillEventLog('DnsEvent.Evt');
end;
//=================ClearEventLog结束===================