编程使计算机休眠

void CPage1::OnXiuMian() { if(MessageBox(“确实要休眠吗?”,”关机程序”,MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION)==IDYES) { static HANDLE hToken; static TOKEN_PRIVILEGES tp; static LUID luid; if(::OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &hToken;)) { ::LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&luid;); tp.PrivilegeCount=1; tp.Privileges[0].Luid =luid; tp.Privileges[0].Attributes =SE_PRIVILEGE_ENABLED; ::AdjustTokenPrivileges(hToken,false,&tp;,sizeof(TOKEN_PRIVILEGES),NULL,NULL); } ::SetSystemPowerState(false,true); } }

支持原创技术分享,据说打赏我的人,都找到了女朋友!