如何屏蔽热键Alt+F4(50分)

  • 主题发起人 xie_huan
  • 开始时间
X

xie_huan

Unregistered / Unconfirmed
GUEST, unregistred user!
调用函数SystemParametersInfo(SPI_SCREENSAVERRUNNING,0,@temp,0)后,只屏蔽了Alt+Esc<br>,Alt+Tab和Ctrl+Alt+Del热贱,无法屏掉Alt+F4<br>
 
用KEYDOWN事件来屏弊了可以啊!
 
在你的Form的OnKeyDown里面写代码就可以了。
 
我刚学DELPHI不久,能否详细点,谢谢
 
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;Shift: TShiftState);<br>begin<br>if (ssAlt in shift)and(key=115) then key:=0;<br>end;<br>就可以了
 
看看我以前的贴子,不好意思,我忘了id了![:)]
 
用HOOK!
 
onCloseQuery(canclose :booean);<br>begin<br>Canclose :=false;<br>end;
 
向系统注册Alt+F4热键,然后在代码里什么也不做,这样可以屏蔽全局的 Alt+F4:<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; &nbsp; HotKeyId: Integer;<br>&nbsp; &nbsp; procedure HotKeyDown(var Msg: Tmessage); message WM_HOTKEY; &nbsp;//热键消息响应<br><br>procedure TForm1.HotKeyDown(var Msg: Tmessage);<br>begin<br>&nbsp; if (Msg.LparamLo = Mod_Alt) And (Msg.LParamHi = VK_F4) then <br>&nbsp; begin<br>&nbsp; &nbsp; ; // 什么也不做,呵呵, 不写也行<br>&nbsp; end;<br>end;<br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>&nbsp; HotKeyId := GlobalAddAtom('HotKey') - $C000;<br>&nbsp; RegisterHotKey(Handle, hotkeyid, Mod_Alt, VK_F4);<br>end;<br>procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br>&nbsp; UnRegisterHotKey(handle, HotKeyId);<br>end;<br><br>
 
用键盘钩子。
 
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;<br>&nbsp; Shift: TShiftState);<br>begin<br>&nbsp; &nbsp; &nbsp; &nbsp;SystemParametersInfo(Spi_screensaverrunning,1,@temp,0);<br>&nbsp; &nbsp; &nbsp; &nbsp; if (Key=VK_F4) and (ssAlt in shift) then<br>&nbsp; &nbsp; &nbsp; &nbsp; Key :=0;<br><br>end;
 
有一个简单的办法,告诉你你会笑掉大牙的,但确实 Windows 是这样给加上 Alt-F4 的,<br>所以这个方法只要是 Windows ,不论版本都可使用。
 
谢谢各位!
 
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;<br>&nbsp; Shift: TShiftState);<br>begin<br>if((Key=VK_F4) AND (ssAlt in &nbsp;Shift)) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Key:=0;<br>end;<br>这是唯一的最简单的方法!!!
 
顶部