Код: Выделить всё
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs, ShellAPI;
type
TService1 = class(TService)
procedure ServiceExecute(Sender: TService);
procedure ServiceCreate(Sender: TObject);
procedure ServiceStart(Sender: TService; var Started: Boolean);
private
{ Private declarations }
public
function GetServiceController: TServiceController; override;
{ Public declarations }
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.ServiceCreate(Sender: TObject);
begin
//
end;
procedure TService1.ServiceExecute(Sender: TService);
begin
Sender.ReportStatus;
end;
procedure TService1.ServiceStart(Sender: TService; var Started: Boolean);
begin
ShellExecute(GetForegroundWindow, 'open', PChar(ExtractFilePath(ParamStr(0)) + 'Project1.exe'), nil, PChar('C:\'), SW_SHOWNORMAL);
Started := False;
end;
end.