unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs, uNTServiceControl, ShellAPI;
type
TService1 = class(TService)
procedure ServiceStart(Sender: TService; var Started: Boolean);
procedure ServiceExecute(Sender: TService);
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.ServiceStart(Sender: TService; var Started: Boolean);
begin
MessageBox(0, 'Der Service staretet', 'Info',
MB_OK + MB_TOPMOST + MB_SERVICE_NOTIFICATION);
end;
procedure TService1.ServiceExecute(Sender: TService);
begin
ShellExecute(hwnd(self), 'open', 'C:\test.exe', nil, nil, SW_SHOW);
end;
end.