Reputation: 397
I have created a console application that runs through a windows service.
Service starts the application and runs it well.
The problem is when i attempt to restart/shutdown my PC, application is closing before the actual shutdown.
So what happens is the service restarts the application again before shutdown.
Even I tried without service. Application is closing before shutdown.
How can I tell my service to know that pc is going to shutdown/restart. So dont restart the application.
Can anyone help me with this ?
Upvotes: 0
Views: 740
Reputation: 37192
Your service can register for notification with RegisterServiceCtrlHandlerEx
and will receive the SERVICE_CONTROL_PRESHUTDOWN
notification when the shutdown process begins. See http://msdn.microsoft.com/en-us/library/windows/desktop/ms685149(v=vs.85).aspx for more information.
Upvotes: 3