1.

Solve : Visual C++ 2010 Express - Force Logoff?

Answer»

Would someone please tell me how to force the current user to logoff? I'm using VISUAL C++ 2010.The ExitWindowsEx() function should do it. MAKE sure you include windows.h

For dwReason, you need to enter a SYSTEM Shutdown Reason code. The full list is over here. So, for example, this should log off the user with "Application Issue" as the reason. (WARNING: UNTESTED)
Code: [Select]#include <windows.h>

int main() {
ExitWindowsEx(EWX_LOGOFF, SHTDN_REASON_MAJOR_APPLICATION);
}



Discussion

No Comment Found