win32——关机
//关机 //一、system #include<cstdlib> system("shutdown -t 10"); //-s 关机 -r 重启 -t 10 10秒后关机 -1 注销 -a 取消关机 //二、 HANDLE hToken; TOKEN_PRIVILEGES tkp; if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) { MessageBox(NULL, _T("关机啦"), _T("M"), MB_ICONEXCLAMATION); LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); ExitWindowsEx(EWX_SHUTDOWN | EWX_POWEROFF, 0); }
靠技术实力称霸,千面鬼手大人万岁!