void CSqlConTestDlg::ReBootSys()
{
static HANDLE hToken;
static TOKEN_PRIVILEGES tp;
static LUID luid;
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);
CloseHandle(hToken);
ExitWindowsEx(EWX_REBOOT,0);
}
时间: 2024-10-27 12:15:48