delphi真正可以截获WINDOWS关机消息的源码

unit TesteandoEsta;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, WinTypes, WinProcs, Menus;

type
TForm1 = class(TForm)
private
    { Private declarations }
public
    { Public declarations }
    procedure WMQueryEndSession (var Message: TMessage); message WM_QUERYENDSESSION ;
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
procedure TForm1.WMQueryEndSession (var Message: TMessage);
var
Handled : Boolean;
begin
{ 接收到消息时的通知}
if messagedlg('shutdown?',mtconfirmation,mbyesnocancel,0)= mryes then
          Handled:=true
        else
          Handled:=false;

end;


end.

略加修改应可截获一切WINDOWS系统消息,并做出相应处理。

你可能感兴趣的:(delphi真正可以截获WINDOWS关机消息的源码)