unit SocketSvrUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs;
type
TSocketService = class(TService)
procedure ServiceContinue(Sender: TService; var Continued: Boolean);
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 declarations }
public
function GetServiceController: TServiceController; override;
{ Public declarations }
end;
var
SocketService: TSocketService;
implementation
uses
MainFrmUnit;
{$R *.DFM}
procedure ServiceController(CtrlCode: DWord); stdcall;
begin
SocketService.Controller(CtrlCode);
end;
function TSocketService.GetServiceController: TServiceController;
begin
Result := ServiceController;
end;
procedure TSocketService.ServiceContinue(Sender: TService;
var Continued: Boolean);
begin
while not Terminated do begin
Sleep(10);
ServiceThread.ProcessRequests(False);
end;
end;
procedure TSocketService.ServiceExecute(Sender: TService);
begin
while not Terminated do begin
Sleep(10);
ServiceThread.ProcessRequests(False);
end;
end;
procedure TSocketService.ServicePause(Sender: TService;
var Paused: Boolean);
begin
Paused := True;
end;
procedure TSocketService.ServiceShutdown(Sender: TService);
begin
Status := csStopped;
ReportStatus();
end;
procedure TSocketService.ServiceStart(Sender: TService;
var Started: Boolean);
begin
Started := True;
Svcmgr.Application.CreateForm(TMainFrm, MainFrm);
MainFrm.Show;
end;
procedure TSocketService.ServiceStop(Sender: TService;
var Stopped: Boolean);
begin
Stopped := True;
MainFrm.Free;
end;
end.