搞定了,是从MSDN中抄的,只不过原来的是用VB写的<br>我改成了Delphi的。我的系统是NT,满足你的要求。<br>但是不知道在98侠好不好用,你试试。<br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br><br> private<br> { Private declarations }<br> procedure AdjustToken;<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<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><br>end.<br>