to asnhchen窗口上放个button一按这个就重启了,没拦住。unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button3: TButton; procedure Button3Click(Sender: TObject); private { Private declarations } procedure WMQueryEndSession(var msg:TMessage); message WM_QueryEndSession; public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure operatecomputer(statue:longword);{ statue: ewx_logoff, ewx_poweroff, ewx_reboot}var hToken:THandle; tkp : TOKEN_PRIVILEGES; ReturnLength : DWord;begin if (not OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES or TOKEN_ALL_ACCESS or TOKEN_QUERY, hToken))then Exit; LookupPrivilegeValue(nil,'SeShutdownPrivilege',tkp.Privileges[0].Luid); tkp.PrivilegeCount := 1; tkp.Privileges[0].Attributes :=SE_PRIVILEGE_ENABLED; ReturnLength :=0; AdjustTokenPrivileges(hToken, FALSE, tkp, 0,nil,ReturnLength); if (GetLastError() <> ERROR_SUCCESS) then Exit; if (not ExitWindowsEx(statue, 0)) then Exit;end; procedure TForm1.WMQueryEndSession(var msg:TMessage); begin msg.Result:=0; //为1表示允许,为0表示不允许 end; procedure TForm1.Button3Click(Sender: TObject);begin operatecomputer(ewx_reboot);end;end.