PRB: ExitWindowsEx with EWX_LOGOFF Doesn't Work Properly (149690)



The information in this article applies to:

  • Microsoft Platform Software Development Kit (SDK) 1.0

This article was previously published under Q149690

SYMPTOMS

When 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.

CAUSE

It 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.

RESOLUTION

The most robust way to use ExitWindowsEx with EWX_LOGOFF is to create a separate application that does nothing but call ExitWindowsEx(EWX_LOGOFF, 0) and then exits. This method will work correctly on all platforms that support ExitWindowsEx. This application must be a Windows application or a console application.

Code similar to the following will correctly perform a logoff on all Windows platforms that support ExitWindowsEx:
   int PASCAL WinMain(  HINSTANCE hInstance,
                        HINSTANCE hPrevInstance,
                        LPSTR lpCmdLine,
                        int nCmdShow)
   {
   ExitWindowsEx(EWX_LOGOFF, 0);

   return 0;
   }
				

STATUS

This behavior is by design.

Modification Type:MinorLast Reviewed:7/11/2005
Keywords:kbprb kbWndw KB149690