关机代码
2008-03-08 12:41:55 来源:WEB开发网核心提示://Win2000&WinNT实现的代码HANDLE hToken;TOKEN_PRIVILEGES tkp;if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGESTOKEN_QUERY, &hToken)){LookupPrivilegeVa
//Win2000&WinNT实现的代码
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGESTOKEN_QUERY, &hToken))
{
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
ExitWindowsEx(EWX_SHUTDOWNEWX_POWEROFF, 0);
}
//Win9x实现的代码
ExitWindowsEx(EWX_SHUTDOWNEWX_POWEROFF, 0);
更多精彩
赞助商链接