《C++电脑关机程序代码.docx》由会员分享,可在线阅读,更多相关《C++电脑关机程序代码.docx(2页珍藏版)》请在三一办公上搜索。
1、C+电脑关机程序代码#include <windows.h>#include <iostream>using namespace std;int main(int argc,char *argv)HANDLE hToken; TOKEN_PRIVILEGES tkp; if (!OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken) cout<<OpenProcessToken<<endl; LookupPrivilegeValue(NULL, SE_
2、SHUTDOWN_NAME, &tkp.Privileges0.Luid); tkp.PrivilegeCount = 1; / one privilege to set tkp.Privileges0.Attributes = SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); if (GetLastError != ERROR_SUCCESS) cout<<AdjustTokenPrivileges<<endl; if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 0) cout<<ExitWindowsEx<<endl;