阻止Windows2000的电源按钮(Power)(0分)

  • 主题发起人 主题发起人 delphiwolf
  • 开始时间 开始时间
D

delphiwolf

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure WMPowerBroadcast(var message: TMessage);
message WM_POWERBROADCAST;
procedure TForm1.WMPowerBroadcast(var message: TMessage);
begin
message.Result := BROADCAST_QUERY_DENY;
end;
 
hehe,报个到,谢了
 
unit CPower;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
procedure FormPaint(Sender: TObject);
private
{ Private declarations }
procedure WMPowerBroadcast(var message: TMessage);
message WM_POWERBROADCAST;
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.DFM}
{ TForm1 }
procedure TForm1.WMPowerBroadcast(var message: TMessage);
const SkipNextPowerMsg:boolean=True;
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;

procedure TForm1.FormPaint(Sender: TObject);
begin
Self.Visible:=False;
end;

end.
 
嘿嘿,不客气。
 
最好的方法是把那个键抠掉(玩笑)
 
接受答案了.
 
我要几个系统能兼容,缺了WinMe/Win98可不行啊。。。
 
后退
顶部