Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

My service won't start - error 1053

Posted on 2004-08-22
10
Medium Priority
?
2,423 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

705 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