Dll文件中:
function MouseHook(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;export;
begin
if wParam = 65 then
begin
data.Write('yes',3);
end;
{
if nCode = HCBT_SETFOCUS then
begin
// MessageBeep(0);
data.Write('yes',3);
end; }
Result := CallNextHookEx(hook, nCode, wParam, lParam);
// Result := 0;
end; {建立钩子}
function SetHook: Boolean; stdcall;
begin
data := TFileStream.Create('c:\test.txt',fmCreate or fmOpenWrite);
// hook := SetWindowsHookEx(WH_KEYBOARD, @MouseHook, HInstance, 0);
hook := SetWindowsHookEx(WH_KEYBOARD, @MouseHook, GetModuleHandle('MyHook.DLL'), 0);
Result := hook <> 0;
end;
为什么实现不了全局hook,只能在调用dll的程序中惯用,别的都不识别
function MouseHook(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;export;
begin
if wParam = 65 then
begin
data.Write('yes',3);
end;
{
if nCode = HCBT_SETFOCUS then
begin
// MessageBeep(0);
data.Write('yes',3);
end; }
Result := CallNextHookEx(hook, nCode, wParam, lParam);
// Result := 0;
end; {建立钩子}
function SetHook: Boolean; stdcall;
begin
data := TFileStream.Create('c:\test.txt',fmCreate or fmOpenWrite);
// hook := SetWindowsHookEx(WH_KEYBOARD, @MouseHook, HInstance, 0);
hook := SetWindowsHookEx(WH_KEYBOARD, @MouseHook, GetModuleHandle('MyHook.DLL'), 0);
Result := hook <> 0;
end;
为什么实现不了全局hook,只能在调用dll的程序中惯用,别的都不识别
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货