On Mon, 1 May 2017 11:44:17 +0200, R.Wieser wrote:
> Hello All,
>
> I've got a program which has a rather time-lengthy WM_ENDSESSION (system
> shutdown) procedure, and I'm wondering how to, after it has finished, tell
> the system to proceed with the shutdown.
>
> I could just execute another system shutdown, but am wondering if there
> isn't something build-in which does that job.
There's none, for both.
Windows WM_QUERYENDSESSION is more of a notification rather than a query,
because if an application doesn't respond within 5 seconds, it would treat
the application as unresponsive, and will still proceed the system shutdown
procedure anyway.
> Also, when I have to run another system shutdown than how should I protect
> my app from receiving it too* (and restart the lengthy WM_ENDSESSION
> procedure) ? I could execute a PostQuitMessage, but I could imagine that
> causing a race condition (between the actual quitting and another
> WM_ENDSESSION being received -- which would be bad).
>
> *I could ofcourse introduce a flag which gets set at the end of the
> WM_ENDSESSION procedure and tested/used by WM_QUERYENDSESSION to see if the
> shutdown should be cancelled or not, but if thats not needed than is just
> extra work for nothing. :-)
That flag is required if your application is the one that initiates the
system shutdown, and your application needs to know whether a system
shutdown was initiated by itself or not. Simply because neither
WM_QUERYENDSESSION or WM_ENDSESSION includes information regarding which
application initiated the system shutdown.
> By the way: MSDN mentions nothing in that direction, and neither did some
> googeling turn up anything in this regard ...
>
> I almost forgot: Its for Win98se (if that makes any difference).
Doesn't make a difference, really. Even all the new functions in NT, XP,
Vista+ doesn't provide a way to pause a system shutdown. You can either
allow or reject. You can delay but only for 5 seconds.