T
txbdir
Unregistered / Unconfirmed
GUEST, unregistred user!
请问如何禁止强制关闭计算机?
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose :=False;
end;
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
WantClose: boolean;
procedure WndProc(var Message: TMessage); override;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
{ TForm1 }
procedure TForm1.WndProc(var Message: TMessage);
begin
case Message.Msg of
WM_QUERYENDSESSION:
if not WantClose then
exit;
end;
inherited;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
WantClose:= true;
end;
end.
上面两种方法都不行!
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose :=False;
end;
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
WantClose: boolean;
procedure WndProc(var Message: TMessage); override;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
{ TForm1 }
procedure TForm1.WndProc(var Message: TMessage);
begin
case Message.Msg of
WM_QUERYENDSESSION:
if not WantClose then
exit;
end;
inherited;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
WantClose:= true;
end;
end.
上面两种方法都不行!