Do you create services with Delphi? Then maybe you are also annoyed at the time consuming way of starting, restarting, killing and attaching to the service process application every time. Well, there is remedy.
You don’t need to do this. Instead run Delphi as a SYSTEM application and do some minor adaptions to the service code. How?
Download and use RunAsSys and do the following code adaption:
Just define APPMODE in the compiler directive options in the project settings and you can run the service as a normal application.
Okay that is not the whole truth. The parameter property of TService does not work, too. So we have to introduce helper functions.
function TMyService._Param(index : Integer) : String;
begin
{$IFDEF APPMODE}
result := System.ParamStr(Index);
{$ELSE}
try
result := Self.Param[Index];
except
result := ”;
end;
{$ENDIF}
end;
And finally there is the Session 0 problem. If your service needs the Session 0 to be used you cannot use this approach in Vista. However this is very rare and honestly I don’t know any reason. Of course all functions like WTSQueryUserToken which insist upon the SYSTEM token, will work fine.
6 Responses
Christophe Rozec
07|May|2008 1Hello,
it seems very useful but i do not manage to use this with one of my service ?
what is XPService in the instruction : XPService.ServiceExecute(nil); ?
what do i missed ?
Thanks,
Christophe
Christian Wimmer
07|May|2008 2Yes, this is a copy&paste error. It should read My instead of XP. I already adapted it.
The method ServiceExecute is the main service execution procedure of your service. We just call it directly.
Ritsaert Hornstra
13|May|2008 3Shoudn’t you use a thread per service and run the serviceexecute per thread and a main thread that waits for until all service threads are terminated?
Christian Wimmer
13|May|2008 4The service per thread solution is fine. However the topic is about how you can debug a service without using the service manger.
Setting the SessionID for a new process by JEDI Windows API
23|May|2008 5[...] you know? 1. You can test this example in your own Delphi environment without writing a service [...]
So you want to write a service… by JEDI Windows API
28|Nov|2008 6[...] You cannot debug a service like any other application by default. Luckily there is remedy. The JEDI API offers a RunAsSys application that lets you start your Delphi in the SYSTEM context. In this way you just have to do a minor patch to your service source code to make it run like any other application in Delphi. See my post Debugging services: an easy way. [...]
Leave a reply
Search
Paypal donation (EUR)
Categories
Archives
Tags
Recent Posts
Recent Comments
Blogroll
JEDI Sites
Pages
A design creation of Design Disease
Copyright © 2007 - JEDI Windows API - is proudly powered by WordPress
InSense 1.0 Theme by Design Disease brought to you by HostGator Web Hosting.