PRB: ExitWindowsEx with EWX_LOGOFF Doesn't Work ProperlyLast reviewed: April 11, 1996Article ID: Q149690 |
The information in this article applies to:
SYMPTOMSWhen an application calls ExitWindowsEx with EWX_LOGOFF in Windows 95, the application itself does not exit. Additionally, the use of the EWX_FORCE flag in conjunction with EWX_LOGOFF will cause undefined behavior.
CAUSEIt is the application's responsibility to terminate itself. However, limitations of the implementation of ExitWindowsEx in Windows 95 require that the application execute the ExitWindowsEx call and terminate itself in a particular way.
RESOLUTIONCode similar to the following will correctly perform a logoff in Windows 95:
case IDM_LOGOFF: { DWORD dw; HANDLE hThread; g_hwndParent = hWnd; hThread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)ShutdownThread, (LPVOID)0, 0, &dw); if(hThread) CloseHandle(hThread); } break; /************************************************************************** ShutdownThread()**************************************************************************/ BOOL WINAPI ShutdownThread(DWORD dwCmd) { BOOL f; f = ExitWindowsEx(EWX_LOGOFF, 0);
//if the shutdown worked, terminate the calling appif(f) { if(g_hwndParent) { //shutdown the calling app ASAP, don't destroy the window PostMessage(g_hwndParent, WM_QUIT, 0, 0); } }return f; }
STATUSThis behavior is by design.
|
Additional reference words: 4.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |