C
Craig Peacock
Is it possible to determine from a service if a computer is shutting
down or rebooting, or if it is suspending or hibernating?
I currently have an NT service which can perform some lengthy
background tasks. If a user tries to shutdown the computer I want to
hold up the process until the background task finishes.
At present I get the WM_QUERYENDSESSION and WM_POWERBROADCAST messages
which I fail and display a dialog to the user that the background task
is running and the computer will reboot/shutdown or suspend/hibernate
as soon as the process finishes.
I can determine from the WM_QUERYENDSESSION if the user is logging out
or shutting down/rebooting, but I can differentiate between the
shutdown and reboot. Likewise with the WM_POWERBROADCAST, I can't
differentiate if the computer is hibernating or suspending. As a
consequence it makes it hard to reschedule the operation later.
If I simply hold the notification message, windows will start shutting
down my app in 30 seconds. I need to hold it off for a period of
minutes.
Regards,
Craig
down or rebooting, or if it is suspending or hibernating?
I currently have an NT service which can perform some lengthy
background tasks. If a user tries to shutdown the computer I want to
hold up the process until the background task finishes.
At present I get the WM_QUERYENDSESSION and WM_POWERBROADCAST messages
which I fail and display a dialog to the user that the background task
is running and the computer will reboot/shutdown or suspend/hibernate
as soon as the process finishes.
I can determine from the WM_QUERYENDSESSION if the user is logging out
or shutting down/rebooting, but I can differentiate between the
shutdown and reboot. Likewise with the WM_POWERBROADCAST, I can't
differentiate if the computer is hibernating or suspending. As a
consequence it makes it hard to reschedule the operation later.
If I simply hold the notification message, windows will start shutting
down my app in 30 seconds. I need to hold it off for a period of
minutes.
Regards,
Craig