windows重启系统

来源:互联网 发布:chrome js 拷贝 编辑:程序博客网 时间:2024/05/14 17:23
// 重启系统BOOL SystemShutDown(){    HANDLE hToken;     TOKEN_PRIVILEGES tkp;     // Get a token for this process.     OpenProcessToken(GetCurrentProcess(),         TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken);    // Get the LUID for the shutdown privilege.     LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,         &tkp.Privileges[0].Luid);     // Modify token    tkp.PrivilegeCount = 1;  // one privilege to set        tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;     // Get the shutdown privilege for this process.     AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,         (PTOKEN_PRIVILEGES)NULL, 0);     // Shut down the system and force all applications to close.     return ExitWindowsEx(EWX_REBOOT, 0);}

原创粉丝点击