bool shutdown() { HANDLE token; if(!OpenProcessToken (GetCurrentProcess (), TOKEN_ADJUST_PRIVILEGES, &token)) return false; LUID luid; if(!LookupPrivilegeValue (NULL, SE_SHUTDOWN_NAME, &luid)) return false; TOKEN_PRIVILEGES tp; tp.PrivilegeCount = 1; tp.Privileges[0].Luid = luid; tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; if(!AdjustTokenPrivileges(token, FALSE, &tp, 0, 0, 0)) return false; if(ExitWindowsEx(EWX_SHUTDOWN|EWX_FORCE, 0)) return true; else return false; }