Export (0) Print
Expand All

How to Log Off the Current User

The following example uses the ExitWindows function to log off the current user.

// Log off the current user. 

ExitWindows(0, 0);

The following example uses the ExitWindowsEx function to log off the current user.

// Log off the current user. 

ExitWindowsEx(EWX_LOGOFF, 0);

The application receives the WM_QUERYENDSESSION message and displays a dialog box asking the whether it is OK to end the session. If the user clicks Yes, the system logs off the user. If the user clicks No, the logoff is canceled.

// Process the message in the window procedure. 

case WM_QUERYENDSESSION:  
{ 
    int r; 
    r = MessageBox(NULL,(LPCWSTR)L"End the session?",(LPCWSTR)L"WM_QUERYENDSESSION",MB_YESNO);
 
    // Return TRUE to continue, FALSE to stop. 
 
    return r == IDYES; 
    break; 
}

Related topics

Logging Off

 

 

Community Additions

ADD
Show:
© 2014 Microsoft