//winxp下屏蔽win键的dll,调用BeginHook和EndHook就可以了.<br>library HookDLL;<br>uses<br> Windows, SysUtils, Messages;<br><br>var<br> KeyHook: HHook;<br><br>function HookKey(Code: integer; wParam: wParam; lParam: lParam): LRESULT; stdcall;<br>type<br> PKBDLLHOOKSTRUCT = ^KBDLLHOOKSTRUCT;<br> KBDLLHOOKSTRUCT = record<br> vkCode: DWORD;<br> ScanCode: DWORD;<br> Flags: DWORD;<br> Time: DWORD;<br> dwExtraInfo: DWORD;<br> end;<br>begin<br> //屏蔽win键<br> if (Code = HC_ACTION) and ((PKBDLLHOOKSTRUCT(lParam).vkCode = VK_LWIN)<br> or (PKBDLLHOOKSTRUCT(lParam).vkCode = VK_RWIN)) then begin<br> Result := 1<br> end<br> else<br> Result := CallNextHookEx(KeyHook, Code, wParam, lParam);<br>end;<br><br>procedure BeginHook;<br>begin<br> KeyHook := SetWindowsHookEx(13{=WH_KEYBOARD_LL}, @HookKey, HInstance, 0);<br>end;<br><br>procedure EndHook;<br>begin<br> UnhookWindowsHookEx(KeyHook);<br>end;<br><br>exports<br> BeginHook, EndHook;<br><br>begin<br><br>end.<br><br><br>//exe调用例子<br>unit FrmExe;<br><br>interface<br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, ExtCtrls, StdCtrls, Buttons;<br><br>type<br> TForm1 = class(TForm)<br> btn1: TButton;<br> btn2: TButton;<br> procedure btn1Click(Sender: TObject);<br> procedure btn2Click(Sender: TObject);<br> procedure FormClose(Sender: TObject; var Action: TCloseAction);<br> private<br><br> public<br><br> end;<br><br>var<br> Form1: TForm1;<br><br>procedure BeginHook; external 'HookDLL.dll';<br>procedure EndHook; external 'HookDLL.dll';<br><br>implementation<br><br>{$R *.dfm}<br>procedure TForm1.btn1Click(Sender: TObject);<br>begin<br> BeginHook;<br>end;<br><br>procedure TForm1.btn2Click(Sender: TObject);<br>begin<br> EndHook;<br>end;<br><br>procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br> EndHook;<br>end;<br><br>end.