关机程序关不了机
小弟测试一个xp的关机程序。但是老是效果不好按F9可以运行。但就是关不了机??各位大侠看看哦!!procedure Get_Shutdown_Privilege;//提权
var
rl: Cardinal;
hToken: Cardinal;
tkp: TOKEN_PRIVILEGES;
begin
OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken);
if LookupPrivilegeValue(nil, 'SeShutdownPrivilege', tkp.Privileges[0].Luid) then
begin
tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
tkp.PrivilegeCount := 1;
AdjustTokenPrivileges(hToken, False, tkp, 0, nil, rl);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ExitWindowsEx(EWX_FORCE+EWX_SHUTDOWN,0);
end;
end.