The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Ghirai on September 19, 2006, 08:16:55 AM

Title: Detect shutdown
Post by: Ghirai on September 19, 2006, 08:16:55 AM
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.
Title: Re: Detect shutdown
Post by: mnemonic on September 19, 2006, 08:50:19 AM
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
Title: Re: Detect shutdown
Post by: TNick on September 19, 2006, 09:49:08 AM
For example, WM_QUERYENDSESSION
Title: Re: Detect shutdown
Post by: Tedd on September 19, 2006, 11:11:57 AM
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.)