不懂Delphi,只有求助各位好心人了[em1]
代码如下:
unit Unit1;
interface
uses
    Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,StdCtrls;
type
    TForm1=class(TForm)
    procedure WMPowerBroadcast(var message:TMessage);message WM_POWERBROADCAST;
    private
    {Private declarations}
    public
    {Public declarations}
  end;
var
  Form1:TForm1;

implementation

{$R *.dfm}
procedure TForm1.WMPowerBroadcast(var message:TMessage);
var
  SkipNextPowerMsg:boolean;
begin
  if SkipNextPowerMsg then
    begin
      SetForegroundWindow(Self.Handle);
      if Application.MessageBox('是否关闭系统?','警告',MB_OKCANCEL+MB_DEFBUTTON2)<>IDOK
      then
        begin
          message.Result:=BROADCAST_QUERY_DENY;
          SkipNextPowerMsg:=not SkipNextPowerMsg;
        end
      else
        Close;
   end
  else
    SkipNextPowerMsg:=not SkipNextPowerMsg;
end;
end;