BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Running an XP service

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Deployment
View previous topic :: View next topic  
Author Message
Jennifer Dohmen
Guest





PostPosted: Tue Jul 29, 2003 1:17 pm    Post subject: Running an XP service Reply with quote



Hello,

I have made a very small app and am trying now to run as a service in WinXP.
I have installed the service but I receive the following error when trying
to start it:

Error 1053: The service did not respond to the start control request in a
timely fashion.


Here is my code:

program p_Serv;

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

{$R *.RES}

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


unit u_srv;

interface

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

type
TService1 = class(TService)
procedure ServiceStart(Sender: TService; var Started: Boolean);
private
{ Private declarations }
public
function GetServiceController: TServiceController; override;
{ Public declarations }
end;
procedure GetStarted;
var

Service1: TService1;
Service2: 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
while service1.Status <> csstopped do
begin
Beep;
Sleep(500);
end;
end;

procedure GetStarted;
begin
//service2.Create(service1);
Service1.DoStart;
end;

end.

Does anyone see the problem?

Thanks!


Back to top
Mike Williams (TeamB)
Guest





PostPosted: Tue Jul 29, 2003 2:34 pm    Post subject: Re: Running an XP service Reply with quote



On 29 Jul 2003, "Jennifer Dohmen" <jdohmen (AT) jne (DOT) ca> wrote:

Quote:
procedure TService1.ServiceStart(Sender: TService;
var Started: Boolean);
begin
while service1.Status <> csstopped do
begin
Beep;
Sleep(500);
end;
end;


You're not setting the Started parameter to true.

--
-Mike (TeamB)

Back to top
Jennifer Dohmen
Guest





PostPosted: Tue Jul 29, 2003 6:37 pm    Post subject: Re: Running an XP service Reply with quote



I have changed my code to the following, however the service control manager
is still not repsonding. If I run this as a regular app then it runs fine
but I cannot get the service manager to control it at all. Any other
suggestions?

unit u_srv;

interface

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

type
TService1 = class(TService)
procedure ServiceStart(Sender: TService; var Started: Boolean);
procedure ServiceStop(Sender: TService; var Stopped: Boolean);
procedure ServicePause(Sender: TService; var Paused: Boolean);
procedure ServiceContinue(Sender: TService; var Continued: Boolean);
private
{ Private declarations }
public
function GetServiceController: TServiceController; override;
{ Public declarations }
end;
procedure GetStarted;
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 GetStarted;
begin
service1.DoStart;
end;

procedure TService1.ServiceStart(Sender: TService; var Started: Boolean);
begin
Started:= True;
Service1.DoContinue;

while service1.Status <> csstopped do
begin
Beep;
Sleep(500);
end;
end;

procedure TService1.ServiceStop(Sender: TService; var Stopped: Boolean);
begin
Stopped := service1.DoStop;
end;

procedure TService1.ServicePause(Sender: TService; var Paused: Boolean);
begin
Paused := service1.DoPause;
end;

procedure TService1.ServiceContinue(Sender: TService;
var
Continued: Boolean);
begin
Continued := Service1.DoContinue;
end;

end.


"Mike Williams (TeamB)" <mikew (AT) remove (DOT) aps-soft.com> wrote

Quote:
On 29 Jul 2003, "Jennifer Dohmen" <jdohmen (AT) jne (DOT) ca> wrote:

procedure TService1.ServiceStart(Sender: TService;
var Started: Boolean);
begin
while service1.Status <> csstopped do
begin
Beep;
Sleep(500);
end;
end;


You're not setting the Started parameter to true.

--
-Mike (TeamB)



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Deployment All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.