unit Service;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs,
ExtCtrls;
type
TService1 =
class(TService)
Timer1: TTimer;
procedure ServiceAfterInstall(Sender: TService);
procedure ServiceAfterUninstall(Sender: TService);
procedure ServiceBeforeInstall(Sender: TService);
procedure ServiceBeforeUninstall(Sender: TService);
procedure ServiceContinue(Sender: TService;
var Continued: Boolean);
procedure ServiceCreate(Sender: TObject);
procedure ServiceDestroy(Sender: TObject);
procedure ServiceExecute(Sender: TService);
procedure ServicePause(Sender: TService;
var Paused: Boolean);
procedure ServiceShutdown(Sender: TService);
procedure ServiceStart(Sender: TService;
var Started: Boolean);
procedure ServiceStop(Sender: TService;
var Stopped: Boolean);
private
{ Private-Deklarationen }
public
function GetServiceController: TServiceController;
override;
{ Public-Deklarationen }
end;
var
Service1: TService1;
implementation
{$R *.DFM}
procedure ServiceController(CtrlCode: DWord);
stdcall;
begin
Service1.Controller(CtrlCode);
end;
function TService1.GetServiceController: TServiceController;
begin
Result := ServiceController;
end;
procedure TService1.ServiceAfterInstall(Sender: TService);
begin
ShowMessage('
AfterInstall');
end;
procedure TService1.ServiceAfterUninstall(Sender: TService);
begin
ShowMessage('
AfterUninstall');
end;
procedure TService1.ServiceBeforeInstall(Sender: TService);
begin
ShowMessage('
BeforeInstall');
end;
procedure TService1.ServiceBeforeUninstall(Sender: TService);
begin
ShowMessage('
BeforeUninstall');
end;
procedure TService1.ServiceContinue(Sender: TService;
var Continued: Boolean);
begin
ShowMessage('
OnContinue');
Continued := True;
end;
procedure TService1.ServiceCreate(Sender: TObject);
begin
ShowMessage('
OnCreate');
end;
procedure TService1.ServiceDestroy(Sender: TObject);
begin
ShowMessage('
OnDestroy');
end;
procedure TService1.ServiceExecute(Sender: TService);
var F: TextFile;
text:
string;
begin
ShowMessage('
OnExecute - begin');
while not Terminated
do
begin
ServiceThread.ProcessRequests(False);
if Timer1.Enabled
then
begin { eine Textdatei öffnen }
AssignFile(f, '
C:\Test.txt');
rewrite(f);
Writeln(f, '
Ich hänge jetzt etwas am Dateiende an.');
CloseFile(f);
end;
end;
ShowMessage('
OnExecute - end');
end;
procedure TService1.ServicePause(Sender: TService;
var Paused: Boolean);
begin
ShowMessage('
OnPause');
Paused := True;
end;
procedure TService1.ServiceShutdown(Sender: TService);
begin
ShowMessage('
OnShutdown');
end;
procedure TService1.ServiceStart(Sender: TService;
var Started: Boolean);
begin
ShowMessage('
OnStart');
Started := True;
end;
procedure TService1.ServiceStop(Sender: TService;
var Stopped: Boolean);
begin
ShowMessage('
OnStop');
Stopped := True;
end;
end.