Service Application

0

Witam
Chciałbym napisać prostą usługę serwisową pod XP. Na początek mam prosty kod, który jednak u mnie nie działa. Nie chce sie wykonywać to co jest w SerivecExecute i ServiceStart. Wykonuje się tylko to co jest w ServiceCreate. Dlaczego!? Poniżej kod:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs,
  ExtCtrls;

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.ServiceExecute(Sender: TService);
begin
Windows.MessageBox(0, 'Execute', 'Title', MB_OK or MB_SERVICE_NOTIFICATION);
while not Terminated do
ServiceThread.ProcessRequests(true);
end;

procedure TService1.ServiceCreate(Sender: TObject);
begin
Windows.MessageBox(0, 'Create', 'Title', MB_OK or MB_SERVICE_NOTIFICATION);
end;

procedure TService1.ServiceStart(Sender: TService;
  var Started: Boolean);
begin
Windows.MessageBox(0, 'Start', 'Title', MB_OK or MB_SERVICE_NOTIFICATION);
end;

end.


program GSMServer;

uses
  SvcMgr,
  Unit1 in 'Unit1.pas' {Service1: TService};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TService1, Service1);
  Application.Run;
end.

0

a że tak głupio zapytam - zainstalowałeś go?

0

Tak. Tak samo sie zachowuje zainstalowany jak odpalany przez Delphi;]

1 użytkowników online, w tym zalogowanych: 0, gości: 1