unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs;
type
TService1 =
class(TService)
procedure ServiceExecute(Sender: TService);
procedure ServiceShutdown(Sender: TService);
procedure ServiceStop(Sender: TService;
var Stopped: Boolean);
private
stopServ : Boolean;
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.ServiceExecute(Sender: TService);
var
sleepCnt : Integer;
begin
AllowStop := true;
stopServ := false;
sleepCnt := 0;
while not stopServ
do
begin
sleep(100);
inc(sleepCnt);
if (
not stopServ)
AND (sleepCnt >= 10)
then
begin
sleepCnt := 0;
beep;
end;
end;
end;
procedure TService1.ServiceShutdown(Sender: TService);
begin
stopServ := true;
self.ServiceThread.Terminate;
ErrCode := 0;
Win32ErrCode := 0;
MessageBeep(2);
end;
procedure TService1.ServiceStop(Sender: TService;
var Stopped: Boolean);
begin
stopServ := true;
ErrCode := 0;
Win32ErrCode := 0;
stopped := true;
end;
end.