Tech Support > Microsoft Windows > Development Resources > InitiateSystemShutdown and ExitwindowsEx
InitiateSystemShutdown and ExitwindowsEx
Posted by Fobzwonkle on June 24th, 2005


I am pulling my hair out.

I want to FORCE a windows shutdown, without
loosing data unless the app misbehaves.
However I have hit a snag.

Calling ExitwindowEx or InitiateSystemShutdown
with FORCE will shut everything down just fine,
except because it does not send
WM_QUERYENDSESSION or WM_ENDSESSION none of the
apps know windows is shutting down, or get
the chance to close. Windows simply terminates
them and I lose data.

If I don't use the FORCE flag and something
like notepad is open, it will stop the entire
shutdown with "do you want to save the file?".

I had also tried calling InitiateSystemShurdown
with FORCE on a 2 minute timer, and then calling
ExitWindowsEx. The idea is that the ExitWindowsEs
will try the nice way (no FORCE), and if it fails
after 2 minutes the InitiateSystemShutdown will
come along and kill the app anyway. Good in theory, but
it does not work. If the ExitWindowEx (no force) gets held up
with the "Save file" crap from notepad, then the
InitiatesystemShutdown (with FORCE) fails.

Is there some simple way around this ?
I don't want to resort to sending WM_QUERYENDSESSION
and WM_ENDSESSION myself if I can avoid it.

Any help appreciated. Cheers.

Posted by Slava M. Usov on June 24th, 2005


"Fobzwonkle" <fobz.spammy@iinet.net.au.crap> wrote in message
news:42bbab20$0$27744$5a62ac22@per-qv1-newsreader-01.iinet.net.au...
Try AbortSystemShutdown() before the second InitiateSystemShutdown().

S




Similar Posts