请问各位大虾怎么样编程才能实现屏蔽CTRL+F4键? 最近我把电脑搬到学校,因为不想让所有的人都胡乱摆弄我的电脑,所以自己编程做了个程序,开机时自动运行,没有密码就不让进入系统,我编程将鼠标限制在一个区域里,屏蔽了所有的系统热键,但是后来有个同学发现了我这个软件的BUG,就是一按CTRL+F4,就能将它关掉,郁闷啊,为什么屏蔽的系统热键里没有CTRL+F4呢?请问各位大虾怎么编程才能实现?请不要对我说要用键盘钩子,一说到钩子我就头疼!先送上100分热热身! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 向系统注册Alt+F4热键,然后在代码里什么也不做,这样可以屏蔽全局的 Alt+F4: private { Private declarations } HotKeyId: Integer; procedure HotKeyDown(var Msg: Tmessage); message WM_HOTKEY; //热键消息响应procedure TForm1.HotKeyDown(var Msg: Tmessage);begin if (Msg.LparamLo = Mod_Alt) And (Msg.LParamHi = VK_F4) then begin ; // 什么也不做,呵呵, 不写也行 end;end;procedure TForm1.FormCreate(Sender: TObject);begin HotKeyId := GlobalAddAtom('HotKey') - $C000; RegisterHotKey(Handle, hotkeyid, Mod_Alt, VK_F4);end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);begin UnRegisterHotKey(handle, HotKeyId);end; 在Form的OnCloseQuery事件中:procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);begin if 密码不对 then CanClose := False;end; 用主form的onkeydown事件,不过最好设置其keypreview为true如此这般就行了:procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);begin {屏蔽 ALT+F4} if (shift = [ssAlt]) and (key = vk_F4) then begin shift := []; key := 0; end;end; 升级到Delphi 2010了,DevExpress5.5谁有汉化或如何汉化 COM+,大家都来讨论下,以解开迷团 shr等于>> 如果是 >>> delphi中用什么代替? TspeedButton使用问题 初学ado问题不少!!! 请问:点击窗体最大化、最小化按钮激发什么事件? 有关心DVD播放和VOD点播系统的大侠请进 win socket编程问题! delphi程序员的工资有多少?与其他vb或c++以及java程序员相比较谁最高? 谁用过TeamSource集成开发,有相关资料吗?高分求取!!! 日历问题 DBGrid问题
private
{ Private declarations }
HotKeyId: Integer;
procedure HotKeyDown(var Msg: Tmessage); message WM_HOTKEY; //热键消息响应procedure TForm1.HotKeyDown(var Msg: Tmessage);
begin
if (Msg.LparamLo = Mod_Alt) And (Msg.LParamHi = VK_F4) then
begin
; // 什么也不做,呵呵, 不写也行
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
HotKeyId := GlobalAddAtom('HotKey') - $C000;
RegisterHotKey(Handle, hotkeyid, Mod_Alt, VK_F4);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
UnRegisterHotKey(handle, HotKeyId);
end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if 密码不对 then CanClose := False;
end;
用主form的onkeydown事件,
不过最好设置其keypreview为true如此这般就行了:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
{屏蔽 ALT+F4}
if (shift = [ssAlt]) and (key = vk_F4) then
begin
shift := [];
key := 0;
end;
end;