怎么屏蔽系统功能键!!!!!!!!!!! ( 积分: 100 )

  • 主题发起人 主题发起人 crosser
  • 开始时间 开始时间
C

crosser

Unregistered / Unconfirmed
GUEST, unregistred user!
下面是我在DLL一断代码<br>function KeyboardHookHandler(iCode: Integer;<br> &nbsp;wParam: WPARAM;lParam: LPARAM): LRESULT; stdcall; export;<br>const<br> &nbsp;_KeyPressMask = $80000000;<br>begin<br> &nbsp;Result := 0;<br> &nbsp;if (lParam and _KeyPressMask)=0 then begin<br> &nbsp; &nbsp; if (GetKeyState(VK_LWIN)&lt;0) then begin<br> &nbsp; &nbsp; &nbsp; &nbsp;messagebox(0,'','',0);<br> &nbsp; &nbsp; &nbsp; &nbsp;Result:=1;<br> &nbsp; &nbsp; end;<br> &nbsp;end;<br> &nbsp;if iCode &lt; 0 then<br> &nbsp; &nbsp;Result := CallNextHookEx(hNextHookProc, iCode, wParam, lParam);<br>end;<br>这样不是不行.上面的代码要是屏蔽不是系统键就可以<br>大家帮帮忙,谁先回答出来,就给分
 
下面是我在DLL一断代码<br>function KeyboardHookHandler(iCode: Integer;<br> &nbsp;wParam: WPARAM;lParam: LPARAM): LRESULT; stdcall; export;<br>const<br> &nbsp;_KeyPressMask = $80000000;<br>begin<br> &nbsp;Result := 0;<br> &nbsp;if (lParam and _KeyPressMask)=0 then begin<br> &nbsp; &nbsp; if (GetKeyState(VK_LWIN)&lt;0) then begin<br> &nbsp; &nbsp; &nbsp; &nbsp;messagebox(0,'','',0);<br> &nbsp; &nbsp; &nbsp; &nbsp;Result:=1;<br> &nbsp; &nbsp; end;<br> &nbsp;end;<br> &nbsp;if iCode &lt; 0 then<br> &nbsp; &nbsp;Result := CallNextHookEx(hNextHookProc, iCode, wParam, lParam);<br>end;<br>这样不是不行.上面的代码要是屏蔽不是系统键就可以<br>大家帮帮忙,谁先回答出来,就给分
 
Var<br> &nbsp;i:integer;<br>systemparametersinfo(spi_screensaverrunning,1,@i,0);
 
这样在NT,2000可以吗,那中只能在98下可行
 
系统键是什么意思?比如。。?
 
unit Unit1;<br><br>interface<br><br>uses<br> &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> &nbsp;Dialogs, StdCtrls;<br><br>type<br> &nbsp;TForm1 = class(TForm)<br> &nbsp; &nbsp;Button1: TButton;<br> &nbsp; &nbsp;procedure FormCreate(Sender: TObject);<br> &nbsp; &nbsp;procedure FormDestroy(Sender: TObject);<br> &nbsp; &nbsp;procedure Button1Click(Sender: TObject);<br> &nbsp;private<br> &nbsp; &nbsp;{ Private declarations }<br> &nbsp;public<br> &nbsp; &nbsp;{ Public declarations }<br> &nbsp;end;<br> &nbsp;KBDLLHOOKSTRUCT=record<br> &nbsp; &nbsp;vkCode:DWORD;<br> &nbsp; &nbsp;scanCode:DWORD;<br> &nbsp; &nbsp;flags:DWORD;<br> &nbsp; &nbsp;time:DWORD;<br> &nbsp; &nbsp;dwExtraInfo:ulong;<br> &nbsp;end;<br> &nbsp;LPKBDLLHOOKSTRUCT=^KBDLLHOOKSTRUCT;<br><br>var<br> &nbsp;Form1: TForm1;<br> &nbsp;//定义句柄<br> &nbsp;OldHook:HHOOK;// 钩子 句柄<br><br>implementation<br><br>{$R *.dfm}<br>const<br>LLKHF_ALTDOWN=$20;<br>WH_KEYBOARD_LL= 13;<br><br>//键盘钩子 &nbsp;封锁 windows 热键<br>function KeyProc(code: Integer; wparam: WPARAM; lparam: LPARAM): LRESULT stdcall;<br>var<br>pkbhs:LPKBDLLHOOKSTRUCT;<br>begin<br><br><br> &nbsp; &nbsp;Result:=1;<br> &nbsp; &nbsp;if (code &lt; 0) then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;Result:= CallNextHookEx(OldHook,code, wParam, lParam);<br> &nbsp; &nbsp; &nbsp; &nbsp;exit;<br> &nbsp; &nbsp;end;<br><br> &nbsp; &nbsp;pkbhs := LPKBDLLHOOKSTRUCT( lParam);<br><br> &nbsp; &nbsp;if (pkbhs.vkCode=91) then//封锁win键<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;exit;<br> &nbsp; &nbsp;end;<br><br> &nbsp; &nbsp;if (pkbhs.vkCode=VK_ESCAPE) and &nbsp;(GetAsyncKeyState(VK_CONTROL)&lt;0) then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;exit; &nbsp;//封锁 CTRL+ESC<br> &nbsp; &nbsp;end;<br><br> &nbsp; &nbsp;if (pkbhs.vkCode=VK_TAB) and (( LLKHF_ALTDOWN and pkbhs.flags)&gt;0) then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;exit; &nbsp;//封锁 ALT+TAB<br> &nbsp; &nbsp;end;<br><br> &nbsp; &nbsp;if (pkbhs.vkCode=115) and ((pkbhs.flags and LLKHF_ALTDOWN)&gt;0) then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;exit; &nbsp;//封锁 ALT+F4<br> &nbsp; &nbsp;end;<br><br> &nbsp; &nbsp;if (pkbhs.vkCode=VK_ESCAPE) and ((pkbhs.flags and LLKHF_ALTDOWN)&gt;0) then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;exit; &nbsp;//封锁 ALT+ESC<br> &nbsp; &nbsp;end;<br><br> &nbsp; &nbsp;if (pkbhs.vkCode=VK_SPACE) and (GetAsyncKeyState(VK_CONTROL)&lt;0) then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;exit; &nbsp;//封锁 CTRL+ ' '<br> &nbsp; &nbsp;end;<br> &nbsp; &nbsp;if (pkbhs.vkCode=VK_SNAPSHOT) then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;exit; &nbsp;//封锁 Print Screen<br> &nbsp; &nbsp;end;<br> &nbsp; &nbsp;if(pkbhs.vkCode=164) then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; exit;<br> &nbsp; &nbsp;end;<br> &nbsp; &nbsp;Result:=CallNextHookEx(OldHook, code, wParam, lParam);<br>end;<br><br>//---------------------------------------------------------------------------<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> &nbsp; OldHook:=0;<br>end;<br><br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br> &nbsp; &nbsp;if OldHook&gt;0 then<br> &nbsp; &nbsp;UnhookWindowsHookEx(OldHook);<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> &nbsp; &nbsp;//注册 钩子<br> &nbsp; &nbsp;OldHook := SetWindowsHookEx(WH_KEYBOARD_LL {WH_KEYBOARD_LL},<br> &nbsp; &nbsp; &nbsp; KeyProc, HInstance, 0);<br> &nbsp; &nbsp;if (Sender is TButton) then<br> &nbsp; &nbsp; &nbsp; TButton(Sender).Enabled:=not (OldHook&gt;0);<br><br>end;<br><br>end.<br><br>=============================<br>以上代码,除了Ctrl+Alt+Del之外基本上的键盘按键都能屏蔽,若是想把C.A.D.也屏蔽掉,可以试着将代码注入到WinLogon.exe进程当中去,以提升权限。
 
谢谢了<br>不过Ctrl+Alt+Del还是不行
 
多人接受答案了。
 

Similar threads

后退
顶部