//调用键盘钩子,屏蔽功能键 function keyHookProc(nCode: Integer; LWParam: WPARAM; LLParam: LPARAM): LRESULT; stdcall; var hHk :HHOOK; //创建勾子 hHk:= SetWindowsHookEx(13, @keyHookProc, HInstance, 0); function keyHookProc(nCode: Integer; LWParam: WPARAM; LLParam: LPARAM): LRESULT;//调用键盘钩子,屏蔽功能键 var p: PKBDLLHOOKSTRUCT; y: integer; begin if nCode < 0 then begin Result:= CallNextHookEx(hHk, nCode, LWParam, LLParam); Exit; end else begin y := 0; case LWParam of WM_KEYDOWN, WM_SYSKEYDOWN, WM_KEYUP,WM_SYSKEYUP: begin p:= PKBDLLHOOKSTRUCT(LLParam); if p^.vkCode = VK_LWIN then y:= 1 else if p^.vkCode = VK_RWIN then y:= 1 else if (p.vkCode = VK_RETURN) and ((p.flags and (KF_ALTDOWN shr 8)) <> 0) and ((GetKeyState(VK_CONTROL) and $8000) <> 0) then y:= 1 else if (p.vkCode = VK_ESCAPE) and ((GetKeyState(VK_CONTROL) and $8000) <> 0) then y:= 1 else if (p.vkCode = VK_ESCAPE) and ((GetKeyState(VK_MENU) and $8000) <> 0) then y:= 1 else if (p.vkCode = 192) and ((GetKeyState(VK_CONTROL) and $8000) <> 0) then y:= 1 else if (p.vkCode = VK_TAB) and ((GetKeyState(VK_MENU) and $8000) <> 0) then y:= 1; end; end; if y=1 then Result:=1 //如果为WIN功能键则屏蔽 else Result:= CallNextHookEx(hHk, nCode, LWParam, LLParam); //其他键放下一个钩子 end end; //卸载勾子 UnHookWindowsHookEx(hHk);
努力加载评论中...
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步