C
Colinyy
Unregistered / Unconfirmed
GUEST, unregistred user!
在WinXP下尝试控制关闭WinXP.编译时出现了以下问题:<br>[Error] AidKit_Unit1.pas(521): Ambiguous overloaded call to 'AdjustTokenPrivileges'<br>请问是为什么?如何解决???<br>谢谢!!!<br>使用以下程序段:<br>procedure TForm1.AdjustToken();<br>var<br> hdlProcessHandle : Cardinal;<br> hdlTokenHandle : Cardinal;<br> tmpLuid : Int64;<br> tkpPrivilegeCount : Int64;<br> tkp : TOKEN_PRIVILEGES;<br> tkpNewButIgnored : TOKEN_PRIVILEGES;<br> lBufferNeeded : Cardinal;<br> Privilege : array[0..0] of _LUID_AND_ATTRIBUTES;<br>begin<br> hdlProcessHandle := GetCurrentProcess;<br> OpenProcessToken(hdlProcessHandle,<br> (TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY),<br> hdlTokenHandle);<br><br> // Get the LUID for shutdown privilege.<br> LookupPrivilegeValue('', 'SeShutdownPrivilege', tmpLuid);<br> Privilege[0].Luid := tmpLuid;<br> Privilege[0].Attributes := SE_PRIVILEGE_ENABLED;<br> tkp.PrivilegeCount := 1; // One privilege to set<br> tkp.Privileges[0] := Privilege[0];<br> // Enable the shutdown privilege in the access token of this<br> // process.<br> AdjustTokenPrivileges(hdlTokenHandle,<br> False,<br> tkp,<br> Sizeof(tkpNewButIgnored),<br> tkpNewButIgnored,<br> lBufferNeeded);<br><br> end;<br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> AdjustToken;<br> ExitWindowsEx((EWX_SHUTDOWN Or EWX_FORCE Or EWX_REBOOT), $FFFF);<br>end;<br>