//------------------------------------------------------------------------------
// NT下提升权限
// 司马华鹏
procedure AdjustTokenPrivilegesNT();
var
hdlProcessHandle:cardinal;
hdlTokenHandle:cardinal;
tmpLuid:int64;
tkp:TOKEN_PRIVILEGES;
tkpNewButIgnored:TOKEN_PRIVILEGES;
lBufferNeeded:cardinal;
begin
hdlProcessHandle:=GetCurrentProcess();
OpenProcessToken(hdlProcessHandle,
TOKEN_ADJUST_PRIVILEGES + TOKEN_QUERY,
hdlTokenHandle);
LookupPrivilegeValue(pChar(''),pChar('SeShutdownPrivilege'),tmpLuid);
tkp.PrivilegeCount := 1;
tkp.Privileges[0].Luid := tmpLuid;
tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hdlTokenHandle, False, tkp,
sizeof(tkpNewButIgnored), tkpNewButIgnored,
lBufferNeeded);
end;
// 强制退出系统
AdjustTokenPrivilegesNT;
ExitWindowsEx(EWX_FORCE or EWX_POWEROFF, 0);