Posted by: Christian Wimmer in: Common
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;
result := System.ParamStr(Index);
result := Self.Param[Index];
result := ”;
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.