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.
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.
ChangeServiceConfig2()
AfterInstall
dwInfoLevel
SERVICE_CONFIG_FAILURE_ACTIONS
lpInfo
SERVICE_FAILURE_ACTIONS
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.
services.msc