主题:[原创]delphi怎么样屏蔽alt+tap和win键?
duck04551
[专家分:90] 发布于 2007-09-19 18:02:00
delphi怎么样屏蔽alt+tap和win键?谢谢各位高手帮忙!
回复列表 (共1个回复)
沙发
punkrocker [专家分:720] 发布于 2007-09-24 10:18:00
下面这个单元
unit UnitHook;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Controls, Forms,
Dialogs, StdCtrls;
type
tagKBDLLHOOKSTRUCT = packed record
vkCode: DWORD;
scanCode: DWORD;
flags: DWORD;
time: DWORD;
dwExtraInfo: DWORD;
end;
KBDLLHOOKSTRUCT= tagKBDLLHOOKSTRUCT;
PKBDLLHOOKSTRUCT = ^KBDLLHOOKSTRUCT;
const WH_KEYBOARD_LL = 13;
const LLKHF_ALTDOWN = $20;
function LowLevelKeyboardProc(nCode:Integer;
WParam: WPARAM;LParam:LPARAM):LRESULT;stdcall;
procedure hookstar;
procedure hookend;
var
hhkLowLevelKybd:HHOOK;
implementation
function LowLevelKeyboardProc(nCode: Integer;WParam: WPARAM;LParam: LPARAM):LRESULT; stdcall;
var
fEatKeystroke: BOOL;
p: PKBDLLHOOKSTRUCT;
begin
Result:=0;
fEatKeystroke:=FALSE;
p:=PKBDLLHOOKSTRUCT(lParam);
if (nCode=HC_ACTION) then
begin
case wParam of
WM_KEYDOWN,
WM_SYSKEYDOWN,
WM_KEYUP,
WM_SYSKEYUP:
fEatKeystroke:=
((p.vkCode=VK_TAB) and ((p.flags and LLKHF_ALTDOWN) <> 0)) or
((p.vkCode=VK_ESCAPE) and ((p.flags and LLKHF_ALTDOWN) <> 0))or
(p.vkCode=VK_Lwin) or
(p.vkCode=VK_Rwin) or
(p.vkCode=VK_apps) or
((p.vkCode=VK_ESCAPE) and ((GetKeyState(VK_CONTROL) and $8000) <> 0)) or
((p.vkCode=VK_F4) and ((p.flags and LLKHF_ALTDOWN) <> 0)) or
((p.vkCode=VK_SPACE) and ((p.flags and LLKHF_ALTDOWN) <> 0)) or
(((p.vkCode=VK_CONTROL) and (P.vkCode = LLKHF_ALTDOWN and p.flags) and (P.vkCode=VK_Delete)))
end;
end;
if fEatKeystroke=True then
Result:=1;
if nCode <> 0 then
Result := CallNextHookEx(0,nCode,wParam,lParam);
end;
procedure hookstar;
begin
if hhkLowLevelKybd=0 then
hhkLowLevelKybd:=SetWindowsHookExW(WH_KEYBOARD_LL,LowLevelKeyboardProc, Hinstance,0);
end;
procedure hookend;
begin
if (hhkLowLevelKybd<>0) and UnhookWindowsHookEx(hhkLowLevelKybd) then
hhkLowLevelKybd:=0;
end;
end.
然后调用hookstar热键不起作用
但是ctrl+alt+del仍然会打开任务管理器
我来回复