unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs,
extctrls, Eventlog;
type
TLogtray =
class(TService)
procedure ServiceCreate(Sender: TObject);
procedure ServiceStart(Sender: TService;
var Started: Boolean);
procedure ServiceContinue(Sender: TService;
var Continued: Boolean);
procedure ServicePause(Sender: TService;
var Paused: Boolean);
private
{ Private-Deklarationen }
mytimer: TTimer;
public
function GetServiceController: TServiceController;
override;
procedure TimerEvent(Sender:Tobject);
procedure Timer;
{ Public-Deklarationen }
end;
var
Logtray: TLogtray;
anz_alt: Integer;
implementation
{$R *.DFM}
procedure TLogtray.TimerEvent(Sender:TObject);
var
anz_neu: Integer;
List: TSTringList;
BEGIN
anz_neu:= getLogNumber('
System');
if anz_neu >= (anz_alt+10)
then
BEGIN
mytimer.Enabled:= false;
getEventLog('
Application', 10, List);
List.SavetoFile('
C:\Application.txt');
getEventLog('
System', 10, List);
List.SavetoFile('
C:\System.txt');
getEventLog('
Security', 10, List);
List.SavetoFile('
C:\Security.txt');
anz_alt:= anz_neu;
mytimer.Enabled:= true;
END;
END;
procedure TLogtray.Timer;
BEGIN
mytimer:= TTimer.create(
nil);
mytimer.interval:= 10000;
mytimer.OnTimer:= TimerEvent;
mytimer.Enabled:= true;
END;
procedure ServiceController(CtrlCode: DWord);
stdcall;
begin
Logtray.Controller(CtrlCode);
end;
function TLogtray.GetServiceController: TServiceController;
begin
Result := ServiceController;
end;
procedure TLogtray.ServiceCreate(Sender: TObject);
begin
anz_alt:= 0;
end;
procedure TLogtray.ServiceStart(Sender: TService;
var Started: Boolean);
begin
Timer;
end;
end.