unit UnitMain;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr;
type
(*----------------------------------------------------------------------------------*)
TSvTProTime = class(TService)
procedure ServiceStart(Sender: TService;
var Started: Boolean);
procedure ServiceStop(Sender: TService;
var Stopped: Boolean);
procedure ServiceExecute(Sender: TService);
procedure ServiceContinue(Sender: TService;
var Continued: Boolean);
private
procedure DisplayForm;
procedure StartServer;
procedure StopServer;
public
bDisplaying: Boolean;
function GetServiceController: TServiceController;
override;
end;
var
SvTProTime: TSvTProTime;
implementation
{$R *.DFM}
uses
Unit1, Forms;
var
F: TForm;
{ methods }
(*--------------------------------------------------------------------------------*)
procedure TSvTProTime.DisplayForm;
begin
if bDisplaying then
Exit;
bDisplaying := True;
F := TForm1.Create(nil);
//F.Show;
end;
(*--------------------------------------------------------------------------------*)
procedure TSvTProTime.StartServer;
begin
bDisplaying := False;
end;
(*--------------------------------------------------------------------------------*)
procedure TSvTProTime.StopServer;
begin
if bDisplaying then
F.Free;
end;
{ events }
(*--------------------------------------------------------------------------------*)
procedure ServiceController(CtrlCode: DWord);
stdcall;
begin
SvTProTime.Controller(CtrlCode);
end;
(*--------------------------------------------------------------------------------*)
function TSvTProTime.GetServiceController: TServiceController;
begin
Result := ServiceController;
end;
(*--------------------------------------------------------------------------------*)
procedure TSvTProTime.ServiceStart(Sender: TService;
var Started: Boolean);
begin
Started := True;
gbCanClose := False;
end;
(*--------------------------------------------------------------------------------*)
procedure TSvTProTime.ServiceStop(Sender: TService;
var Stopped: Boolean);
begin
ServiceThread.Terminate;
Stopped := True;
gbCanClose := True;
end;
(*--------------------------------------------------------------------------------*)
procedure TSvTProTime.ServiceExecute(Sender: TService);
begin
StartServer;
try
while not Terminateddo
begin
ServiceThread.ProcessRequests(False);
Sleep(100);
DisplayForm;
end
finally
StopServer;
end;
end;
procedure TSvTProTime.ServiceContinue(Sender: TService;
var Continued: Boolean);
begin
Continued := True;
end;
end.