小问题:如何检测系统关机消息? ( 积分: 20 )

  • 主题发起人 主题发起人 net_morning
  • 开始时间 开始时间
N

net_morning

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure QueryEndSession(var msg;TMessage);WM_QueryEndSession

Msg.result:=0时禁止关机. 1是允许
 
同意楼上意见

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.
 
多人接受答案了。
 
后退
顶部