How do I exit a windowless app when the system is shutting down. If there was a window then it would receive WM_CLOSE but since there is no window - no message loop. I'd like my app to be able to clean up before closing, so I need to detect shutdown, save data, then close.
Posted on 2003-11-19 05:06:13 by ENF
Would it work if you created a hidden window ?

If you are using a console app:
(from MSDN)
Console processes receive a separate notification message, CTRL_SHUTDOWN_EVENT or CTRL_LOGOFF_EVENT, as the situation warrants. A console process routes these messages to its HandlerRoutine function. ExitWindowsEx sends these notification messages asynchronously; thus, an application cannot assume that the console notification messages have been handled when a call to ExitWindowsEx returns.
Posted on 2003-11-19 06:36:18 by Azrim
thanx for the reply
A hidden window will work and may be the only way to process WM_QUERYENDSESSION. How dose a console application process CTRL_SHUTDOWN_EVENT, I assume there is a function to register a callback?
Posted on 2003-11-19 06:55:39 by ENF
Posted on 2003-11-19 06:57:45 by Azrim
so dose anyone know if windows just calls TerminateProcess on a gui app with no window?
Posted on 2003-11-19 13:21:06 by ENF