C++使用当前进程关闭系统的实现方法
BOOL OpenProcessToken(
HANDLE process HANDLE,//对进程的句柄
DWORD DesiredAccess,//对进程的期望访问
PHANDLE TokenHandle //指向开放访问令牌句柄的指针
);
//GetCurrentProcess()
TOKEN _ PRIVILEGES TP;
处理hToken
OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES,& hToken)
LUID luid;
LookupPrivilegeValue(machine NAME,SE_SHUTDOWN_NAME,&luid)
tp。PrivilegeCount = 1;
tp。权限[0]。Luid = luid
tp。权限[0]。属性= SE _ PRIVILEGE _ ENABLED
AdjustTokenPrivileges(hToken,FALSE,&tp,sizeof(TOKEN_PRIVILEGES),NULL,NULL);//这里是获取权限//
exitwindowsexe(ewx _ power off,ewx _ force);
0条评论