这是那个钩子函数,确实用到了CallNextHookEx,
可是我的意思是把函数的最后一个"Result:=1"也替换成
"Result:=CallNextHookEx(hNextHookProc, iCode, wParam, lParam)"
如果不替换的话,在别的程序里面就接收不到Ctrl+B的消息.
function KeyboardHookHandler(iCode: Integer;
wParam: WPARAM;
lParam: LPARAM): LRESULT; stdcall; export;
const
_KeyPressMask = $80000000;
begin
Result := 0;
If iCode < 0 Then
begin
Result := CallNextHookEx(hNextHookProc, iCode, wParam, lParam);
Exit;
end;
if ((lParam and _KeyPressMask) = 0) and
(GetKeyState(vk_Control) < 0) and (wParam = Ord('B')) then
begin
Result := 1;
//^^^^^^^^^^^
WinExec('Notepad.exe', sw_Normal);
end;
end;