Restart service in case of exception

I am developing a service application that should restart. What are the ways of doing this? Is it possible to request the application to start the system again if it is stopped? I am using Delphi 2007.

+4
source share
2 answers

Your service can program recovery options for itself by calling the ChangeServiceConfig2() Win32 API function inside its AfterInstall event. Set dwInfoLevel to SERVICE_CONFIG_FAILURE_ACTIONS and set lpInfo to point to the SERVICE_FAILURE_ACTIONS entry that describes what you want when the service is down.

+7
source

If you go to services.msc , you can configure this for your service. You do not need to do this in code. Go to the Recovery tab when you open the properties of your service.

+6
source

All Articles