Does anyone know the proper way to detect a shutdown/reboot?
I need to save some stuff in my application before allowing the system to halt.
I suspect it has something to do with the WM_POWERBROADCAST message?
Thanks.
To keep it short, have a look in here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shutdown/base/exitwindows.asp
There are some messages that will be send on the logoff event.
Regards
For example, WM_QUERYENDSESSION
WM_QUERYENDSESSION is sent to all processes to 'ask' if it's okay to shutdown (well, 'end the session' - which usually means shutdown, or just log-out.)
Assuming there are no objections, WM_ENDSESSION is sent to indicate the system will actually be shutting down (if there are objections it won't be sent, and the system won't be shutting down.)