Solved

My service won't start - error 1053

Posted on 2004-08-22
10
2,363 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
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.

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month8 days, 23 hours left to enroll

615 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