RestartApplication in Windows service

delphi package - automated exception handling

RestartApplication in Windows service

Postby mszpcb » Thu Jul 13, 2017 4:32 pm

Hi,

I use MadExcept within a Windows service and want the service to be restartet in case of an exception. Unfortunately neigther setting "automatically restart application" in the configuration dialog nor calling procedure RestartApplication manually (this is my preferred method) seems to work: The service stops but does not come back to life again.
Are there any special settings required for services ("don't show anything" ist already selected)? Is there a way to restart the service with MadExcept?

Many thanks in advance,
Michael
mszpcb
 
Posts: 1
Joined: Thu Jul 13, 2017 4:08 pm

Re: RestartApplication in Windows service

Postby madshi » Thu Jul 13, 2017 4:50 pm

madExcept does not have built in support for restarting services. I don't even know which APIs would need to be called in order to achieve that. For normal applications I simply use "CreateProcess" + "TerminateProcess(myself)". This obviously won't work for services.

If you know how to restart services, you can use "RegisterExceptActionHandler(stDontSync)" to get notified about when the user presses the "restart application" button. In that situation you can then set "handled := true" in your callback function, and then perform the restarting yourself, using your own code.
madshi
Site Admin
 
Posts: 9431
Joined: Sun Mar 21, 2004 5:25 pm


Return to madExcept

Who is online

Users browsing this forum: No registered users and 2 guests