Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


ID: 21933, Debugging Services with Attach to Process

by Simon Carter Email: Anonymous


When using attach to process to debug Services you have to be quick, theres a very simple way of making it easier.
Download Details
FTP  download also available 0 bytes
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 5.0  to 7.0 4 downloads
Copyright: No significant restrictions


Size: 0 bytes
Updated on Tue, 06 Jul 2004 04:19:07 GMT
Originally uploaded on Tue, 06 Jul 2004 04:13:44 GMT
Description
Create a constructor and call the windows Sleep API as follows.

unit Unit1;

interface

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

type
TService1 = class(TService)
private
{ Private declarations }
public
function GetServiceController: TServiceController; override;
constructor Create(AOwner: TComponent); override;
end;

var
Service1: TService1;

implementation

{$R *.DFM}

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

constructor TService1.Create(AOwner: TComponent);
begin
inherited;

{$IFDEF DEBUG}
(* Wait approximately 8 seconds, gives us a chance to
debug from the start of the service *)
Sleep(8000);
{$ENDIF}

//Add code and breakpoint here
end;

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

end.

Although this is a very basic example it gives you enough time to start the service and attach the debugger to it, allowing you to debug the service before the service's start method is called.

rgds

Si Carter
http://www.tectsoft.net/

For more information, see http://www.tectsoft.net/

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC03