//调用键盘钩子,屏蔽功能键 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);