Solved

My service won't start - error 1053

Posted on 2004-08-22
10
2,287 Views
Last Modified: 2008-01-09
Hi,

I write my first service with delphi 7. I can install it but when I try to start it I receive an error 53. The
Service did not respond to the start or control request in a timely fashion.

I can't find the issue. Here is my code :

unit uServProj;

interface

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

type
  TServProj = class(TService)
    Timer1: TTimer;
    procedure ServiceExecute(Sender: TService);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    function GetServiceController: TServiceController; override;
    { Public declarations }
  end;


var
  ServProj: TServProj;

const FileName = 'c:\logfile.txt';

implementation

{$R *.DFM}

procedure ServiceController(CtrlCode: DWord); stdcall;
begin
  ServProj.Controller(CtrlCode);
end;

function TServProj.GetServiceController: TServiceController;
begin
  Result := ServiceController;
end;

procedure TServProj.ServiceExecute(Sender: TService);
begin

 timer1.Enabled := true;

 while not terminated do
 begin
  ServiceThread.ProcessRequests(true);
  timer1.Enabled := false;
 end;


end;

procedure TServProj.Timer1Timer(Sender: TObject);
var f : textfile;
begin

  AssignFile(f,filename);
  if FileExists(filename) then append(f)
  else
    Rewrite(f);

  writeln(f, 'kk');
  ShowMessage('');
  CloseFile(f);

end;

end.

What is wrong ?

Sang-Do
0
Comment
Question by:PHD
  • 4
  • 3
  • 2
10 Comments
 
LVL 12

Expert Comment

by:esoftbg
ID: 11863356
try this:

unit uServProj;

interface

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

type
  TServProj = class(TService)
    Timer1: TTimer;
    procedure ServiceExecute(Sender: TService);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    function GetServiceController: TServiceController; override;
    { Public declarations }
  end;

var
  ServProj: TServProj;

const FileName = 'c:\logfile.txt';

implementation

{$R *.DFM}

procedure ServiceController(CtrlCode: DWord); stdcall;
begin
  try
    ServProj.Controller(CtrlCode);
  except
    on E : Exception do
      ShowMessage(E.Message + ' ServiceController');
  end;
end;

function TServProj.GetServiceController: TServiceController;
begin
  try
    Result := ServiceController;
  except
    on E : Exception do
      ShowMessage(E.Message + ' GetServiceController');
  end;
end;

procedure TServProj.ServiceExecute(Sender: TService);
begin
  try
    timer1.Enabled := true;

    while not terminated do
    begin
      ServiceThread.ProcessRequests(true);
      timer1.Enabled := false;
    end;
  except
    on E : Exception do
      ShowMessage(E.Message + ' ServiceExecute');
  end;
end;

procedure TServProj.Timer1Timer(Sender: TObject);
var f : textfile;
begin
  try
    AssignFile(f,filename);
    if FileExists(filename) then append(f)
    else
      Rewrite(f);

    writeln(f, 'kk');
    ShowMessage('');
    CloseFile(f);
  except
    on E : Exception do
      ShowMessage(E.Message + ' Timer1Timer');
  end;
end;

end.
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 11863392
This way it will be localized the method where the error occurs ....
0
 
LVL 6

Author Comment

by:PHD
ID: 11863716
Thanks esoftbg but I tried your code but nothing happens.

I get no error message excepted the known error message : error 53... .

Sang-Do
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 11863888
I can not test your code, because I never have been write a service ....
If you explain how to install, I will try your code on my computer (I am using Delphi 7 too)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11866482
The message for error 1053 means "The service did not respond to the start or control request in a timely fashion"

When your service starts, it has to update its status to "started" (or "starting" with a progress indicator), otherwise if service control manager won't know when it is successfully started.
0
 
LVL 12

Accepted Solution

by:
Ivanov_G earned 500 total points
ID: 11866497
try using  Self.Status := csRunning; in your ServiceExecute method. Status property is what you should see in Service Control Manager.
0
 
LVL 6

Author Comment

by:PHD
ID: 11867642

To install the service, I donwloaded Srvinstw.exe. When you run the program, a wizard will guide you.

Sang-Do
0
 
LVL 6

Author Comment

by:PHD
ID: 11878416

I also try this :

procedure TServProj.ServiceExecute(Sender: TService);
begin
  try
    timer1.Enabled := true;
    self.Status := csRunning;

    while not terminated do
    begin
      ServiceThread.ProcessRequests(true);
      timer1.Enabled := false;
    end;
  except
    on E : Exception do
      ShowMessage(E.Message + ' ServiceExecute');
  end;
end;

Including the status properties with no more success.

Sang-Do
0
 
LVL 6

Author Comment

by:PHD
ID: 11892686
Ok now it working fine.

The problem : The Displayname property did not match the name of the project.

My project's name is 'Service' and I set the displayname property to service instead of 'loggeduser' and then It starts as expected.

Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
A short film showing how OnPage and Connectwise integration works.

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

1 Experts available now in Live!

Get 1:1 Help Now