Microsoft KB Archive/197630

{|
 * width="100%"|

PRB: Top Level Window Does Not Receive WM_ENDSESSION Messages

 * }

Q197630

-

The information in this article applies to:


 * Microsoft Win32 Software Development Kit (SDK), included with:
 * the operating system: Microsoft Windows NT
 * the operating system: Microsoft Windows 2000

-

SYMPTOMS
On Windows NT, the top-level window in an application that has called AllocConsole does not receive the WM_QUERYENDSESSION and WM_ENDSESSION messages.

CAUSE
The Windows NT shutdown process examines each process to determine if it is a console or GUI process. If any application has created a console using AllocConsole, the shutdown routine "sees" the application as a console application and does not send the WM_QUERYENDSESSION and WM_ENDSESSION messages.

RESOLUTION
This problem can be worked around by calling SetConsoleCtrlHandler to install a console handler routine. This handler routine is called by the system in response to certain events. The two events of interest in this case are CTRL_EVENT_LOGOFF and CTRL_EVENT_SHUTDOWN.

STATUS
This behavior is by design and has been present at least since Windows NT version 3.1.

Additional query words: kbDSupport

Keywords : kbOSWinNT kbOSWin2000 kbSDKPlatform kbSDKWin32 kbGrpDSUser kbWndw kbWndwMsg

Issue type : kbprb

Technology : kbWin32SDKSearch kbAudDeveloper kbSDKSearch kbWin32sSearch