老大不行呀,帮我看看。<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> Label1: TLabel;<br> Label2: TLabel;<br> Edit1: TEdit;<br> procedure Button1Click(Sender: TObject);<br> procedure FormDestroy(Sender: TObject);<br> private<br> { Private declarations }<br> function IsKey(lp: integer):boolean;<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br> hook:integer;<br>implementation<br><br>{$R *.dfm}<br>function tform1.IsKey(lp: integer):boolean;<br>begin<br> result:=false;<br> case lp of<br> 7745: result := true; {A}<br> 12354: result := true;{B}<br> 11843: result :=true; {c}<br> 8260: result := true; {d}<br> 4677: result := true; {e}<br> 8518: result := true; {f}<br> 8775: result := true; {g}<br> 9032: result := true; {h}<br> 5961: result := true; {i}<br> 9290: result := true; {j}<br> 9547: result := true; {k}<br> 9804: result := true; {l}<br> 12877: result := true;{m}<br> 12622: result := true;{n}<br> 6223: result := true; {o}<br> 6480: result := true; {p}<br> 4177: result := true; {q}<br> 4946: result := true; {r}<br> 8019: result := true; {s}<br> 5204: result := true; {t}<br> 5717: result := true; {u}<br> 12118: result := true;{v}<br> 4439: result := true; {w}<br> 11608: result := true;{x}<br> 5465: result := true; {y}<br> 11354: result := true;{z}<br> end;<br>end;<br><br>function hookproc(icode:integer;wparam:wparam;lparam:lparam):lresult;stdcall;<br>const<br> _KeyPressMask = $80000000;<br>//var<br>//evtmsg:teventmsg;<br>begin<br>//evtmsg:=peventmsg(lparam)^;<br>if ((lParam and _KeyPressMask)=0) and (wparam=Ord('B')) then<br> begin<br> Result:=1;<br> // MessageBeep(0);<br> form1.Label1.Caption:='no';<br> end;<br>{if evtmsg.message=WM_keyDOWN then<br> begin<br><br> if form1.IsKey(evtmsg.paramL)=true then<br> form1.Label1.Caption:='不能碰那个键'<br> else<br> form1.Label1.Caption:='可以碰那个键';<br> end;<br>}<br>end;<br><br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>hook:=setwindowshookex(WH_JOURNALRECORD,hookproc,hinstance,0);<br>end;<br><br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br>unhookwindowshookex(hook);<br>hook:=0;<br>end;<br><br>end.<br>