怎样用键盘hook屏蔽掉win键 怎样用键盘hook屏蔽掉win键,win+d,win+f,win+e,有几种方法,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不要这么麻烦用hook啊,把他们注册成热健就可以了,具体看我的帖子http://expert.csdn.net/Expert/topic/2094/2094919.xml?temp=.5023462 unit Udisable;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Controls, Forms,Dialogs, StdCtrls;typetagKBDLLHOOKSTRUCT = packed recordvkCode: DWORD;//????scanCode: DWORD;//????(????){??????,???????,MSDN????????,????????,??????????(???)?1?ALT????0???}flags: DWORD;time: DWORD;//?????dwExtraInfo: DWORD;//??????????end;KBDLLHOOKSTRUCT = tagKBDLLHOOKSTRUCT;PKBDLLHOOKSTRUCT = ^KBDLLHOOKSTRUCT;//?????????????,Delphi???,??????const WH_KEYBOARD_LL = 13;//????????????????flags?????ALT?????const LLKHF_ALTDOWN = $20;//----??????------------- function LowLevelKeyboardProc(nCode: Integer;WParam: WPARAM;LParam: LPARAM):LRESULT; stdcall; procedure hookstar; //???? procedure hookend;varhhkLowLevelKybd: HHOOK;implementation{??:???????????,?????????:nCode ?Hook???WParam ???????LParam ?????????????????KBDLLHOOKSTRUCT??????:????0??windows????????,??????????????}function LowLevelKeyboardProc(nCode: Integer;WParam: WPARAM;LParam: LPARAM):LRESULT; stdcall;varfEatKeystroke: BOOL;p: PKBDLLHOOKSTRUCT;begin Result := 0; fEatKeystroke := FALSE; p := PKBDLLHOOKSTRUCT (lParam); //nCode??HC_ACTION???WParam?LParam????????? if (nCode = HC_ACTION) then begin //????????????Ctrl+Esc?Alt+Tab??Alt+Esc???? case wParam of WM_KEYDOWN, WM_SYSKEYDOWN, WM_KEYUP, WM_SYSKEYUP: fEatKeystroke := ((p.vkCode = VK_TAB) and ((p.flags and LLKHF_ALTDOWN) <> 0)) or // Alt+Tab ((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 //?????WIN?? //((p.vkCode = VK_CONTROL) and (P.vkCode = LLKHF_ALTDOWN) and (P.vkCode = VK_Delete)) 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))) //AND (p.flags = true) ; 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 begin hhkLowLevelKybd := SetWindowsHookExW(WH_KEYBOARD_LL, LowLevelKeyboardProc, Hinstance, 0); if hhkLowLevelKybd <> 0 then //MessageBox(0, '????????!', '??', MB_OK) else // MessageBox(0, '????????!', '??', MB_OK); end else //MessageBox(Handle, '???????!', '??', MB_OK);end;//---------------------??????-----------------procedure hookend;//??????beginif hhkLowLevelKybd <> 0 thenif UnhookWindowsHookEx(hhkLowLevelKybd) <> False thenbegin//MessageBox(0, '????????!', '??', MB_OK);hhkLowLevelKybd := 0;endelse//MessageBox(Handle, '????????!', '??', MB_OK)else//MessageBox(Handle, '????????!', '??', MB_OK);end;//-------------????????-------------------------end.//-------------------????????--------------------function DynamicResolution(X, Y: word): BOOL;var lpDevMode: TDeviceMode;begin Result := EnumDisplaySettings(nil, 0, lpDevMode); if Result then begin lpDevMode.dmFields := DM_PELSWIDTH Or DM_PELSHEIGHT; lpDevMode.dmPelsWidth := X; lpDevMode.dmPelsHeight := Y; lpDevMode.dmDisplayFrequency := 75; Result := ChangeDisplaySettings(lpDevMode, CDS_UPDATEREGISTRY) = DISP_CHANGE_SUCCESSFUL; end; end;end.hookstar 屏蔽hookend 撤销 up 不过不能屏蔽ctrl+alt+del 谢谢linx88(haozi),不过我用delphi5编译执行后并不能屏蔽掉win键,一按win键,开始菜单还是会跳出来,不知我错在哪里,跟踪执行hookend时 hhkLowLevelKybd=0,是不是表示hook没有生成 win2000下测试通过,win98下呢,如何屏蔽win键 把他们注册成热健就可以了,具体看我的帖子http://expert.csdn.net/Expert/topic/2094/2094919.xml?temp=.5023462 谢谢ljmanage(过客),用注册成热健的方法会和其他程序有冲突,难道就没有win98下屏蔽win键的钩子 把它挖掉:)用Hook ,可以参考一下: linx88(haozi) 的贴子 linx88(haozi)的代码只能在2000下用 注册成热健,看我的帖子,你有没有看呢http://expert.csdn.net/Expert/topic/2094/2094919.xml?temp=.5023462里面写着,在程序得到焦点时注册,失去焦点时释放,就不会和别的程序冲突我在其中屏蔽Tab健,没有问题,在别的程序中可以用 求思路~~~~搞不出来啊。 双击dbgrid事件 如何將一個目錄下的所有文件名稱抓取放到一個數組中并按名稱自動排序? 怎样在自己的博克的“公告”下面加入一个图片或是一个时钟? 如何控制stringgrid中某单元格的颜色??******** 如何控制你添加记录的唯一性 如何使我的DELPHI程序节省内存开销? 请教怎么把查询出来的数据另存为其他文件 ____ 100分__ 谁知道visio2000的 key:.... ( 实在找不着)________ 数组如何清空? 请问如何让DL支持多种库单元? 请教一个WEB开发工具选择的问题?
Windows, Messages, SysUtils, Variants, Classes, Controls, Forms,
Dialogs, StdCtrls;
type
tagKBDLLHOOKSTRUCT = packed record
vkCode: DWORD;//????
scanCode: DWORD;//????(????)
{??????,???????,MSDN????????,??
??????,??????????(???)?1?ALT????0???}
flags: DWORD;
time: DWORD;//?????
dwExtraInfo: DWORD;//??????????
end;
KBDLLHOOKSTRUCT = tagKBDLLHOOKSTRUCT;
PKBDLLHOOKSTRUCT = ^KBDLLHOOKSTRUCT;//?????????????,Delphi???,??????
const WH_KEYBOARD_LL = 13;
//????????????????flags?????ALT?????
const LLKHF_ALTDOWN = $20;
//----??????-------------
function LowLevelKeyboardProc(nCode: Integer;
WParam: WPARAM;LParam: LPARAM):LRESULT; stdcall;
procedure hookstar; //????
procedure hookend;
var
hhkLowLevelKybd: HHOOK;
implementation
{
??:???????????,???????
??:nCode ?Hook???
WParam ???????
LParam ?????????????????KBDLLHOOKSTRUCT???
???:????0??windows????????,??????????????
}
function LowLevelKeyboardProc(nCode: Integer;
WParam: WPARAM;LParam: LPARAM):LRESULT; stdcall;
var
fEatKeystroke: BOOL;
p: PKBDLLHOOKSTRUCT;
begin
Result := 0;
fEatKeystroke := FALSE;
p := PKBDLLHOOKSTRUCT (lParam);
//nCode??HC_ACTION???WParam?LParam?????????
if (nCode = HC_ACTION) then
begin
//????????????Ctrl+Esc?Alt+Tab??Alt+Esc????
case wParam of
WM_KEYDOWN,
WM_SYSKEYDOWN,
WM_KEYUP,
WM_SYSKEYUP:
fEatKeystroke :=
((p.vkCode = VK_TAB) and ((p.flags and LLKHF_ALTDOWN) <> 0)) or // Alt+Tab
((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 //?????WIN??
//((p.vkCode = VK_CONTROL) and (P.vkCode = LLKHF_ALTDOWN) and (P.vkCode = VK_Delete)) 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))) //AND (p.flags = true) ;
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
begin
hhkLowLevelKybd := SetWindowsHookExW(WH_KEYBOARD_LL,
LowLevelKeyboardProc,
Hinstance,
0);
if hhkLowLevelKybd <> 0 then
//MessageBox(0, '????????!', '??', MB_OK)
else
// MessageBox(0, '????????!', '??', MB_OK);
end
else
//MessageBox(Handle, '???????!', '??', MB_OK);
end;
//---------------------??????-----------------procedure hookend;//??????
begin
if hhkLowLevelKybd <> 0 then
if UnhookWindowsHookEx(hhkLowLevelKybd) <> False then
begin
//MessageBox(0, '????????!', '??', MB_OK);
hhkLowLevelKybd := 0;
end
else
//MessageBox(Handle, '????????!', '??', MB_OK)
else
//MessageBox(Handle, '????????!', '??', MB_OK);
end;
//-------------????????-------------------------end.//-------------------????????--------------------
function DynamicResolution(X, Y: word): BOOL;
var
lpDevMode: TDeviceMode;
begin
Result := EnumDisplaySettings(nil, 0, lpDevMode);
if Result then
begin
lpDevMode.dmFields := DM_PELSWIDTH Or DM_PELSHEIGHT;
lpDevMode.dmPelsWidth := X;
lpDevMode.dmPelsHeight := Y;
lpDevMode.dmDisplayFrequency := 75;
Result := ChangeDisplaySettings(lpDevMode, CDS_UPDATEREGISTRY) = DISP_CHANGE_SUCCESSFUL;
end;
end;
end.hookstar 屏蔽
hookend 撤销
ctrl+alt+del
会跳出来,不知我错在哪里,跟踪执行hookend时 hhkLowLevelKybd=0,是不是表示hook没有生成
http://expert.csdn.net/Expert/topic/2094/2094919.xml?temp=.5023462
里面写着,在程序得到焦点时注册,失去焦点时释放,就不会和别的程序冲突我在其中屏蔽Tab健,没有问题,在别的程序中可以用