Einzelnen Beitrag anzeigen

Cyberbob_at_tot

Registriert seit: 30. Apr 2003
Ort: Ahlen
270 Beiträge
 
Delphi 2006 Professional
 
#3

Re: Windows Dienst aus Delphi 2006 startet nicht

  Alt 4. Sep 2006, 09:57
OnExecute habe ich noch garnicht benutzt. Wollte nur ein Testprogramm schreiben. Hier der Code...

Code:
unit Unit1;

interface

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

type
  TService1 = class(TService)
    Timer1: TTimer;
    procedure ServiceStop(Sender: TService; var Stopped: Boolean);
    procedure Timer1Timer(Sender: TObject);
    procedure ServiceBeforeInstall(Sender: TService);
    procedure ServiceAfterInstall(Sender: TService);
    procedure ServiceContinue(Sender: TService; var Continued: Boolean);
    procedure ServicePause(Sender: TService; var Paused: Boolean);
    procedure ServiceStart(Sender: TService; var Started: Boolean);
  private
    { Private-Deklarationen }
  public
    function GetServiceController: TServiceController; override;
    { Public-Deklarationen }
  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.ServiceAfterInstall(Sender: TService);
begin
Showmessage('Installiert');
end;

procedure TService1.ServiceBeforeInstall(Sender: TService);
begin
Showmessage('Install wird gestartet');
end;

procedure TService1.ServiceContinue(Sender: TService; var Continued: Boolean);
begin
Timer1.Enabled:=true;
Showmessage('wiederaufgenommen');
end;

procedure TService1.ServicePause(Sender: TService; var Paused: Boolean);
begin
Timer1.Enabled:=false;
Showmessage('Pausiert');
end;

procedure TService1.ServiceStart(Sender: TService; var Started: Boolean);
begin
Timer1.Enabled:=true;
Showmessage('Gestartet');
end;

procedure TService1.ServiceStop(Sender: TService; var Stopped: Boolean);
begin
Timer1.Enabled:=false;
Showmessage('gestopt');
end;

procedure TService1.Timer1Timer(Sender: TObject);
begin
     Showmessage('Aktion');
end;

end.
-----------------------------------------------------------
The only winning move is not to play ! (Wargames)
-----------------------------------------------------------
  Mit Zitat antworten Zitat