各位老大帮我看看这个Hook哪里不对呀(100分)

  • 主题发起人 主题发起人 liangzhang3942
  • 开始时间 开始时间
L

liangzhang3942

Unregistered / Unconfirmed
GUEST, unregistred user!
unit MouseHook;

interface
uses Windows,messages,dialogs;
function MouseHookProc(nCode: Integer;WParam: WPARAM;LParam: LPARAM): LRESULT;stdcall;
function EnableMouseHook:Boolean; stdcall; export;
function DisableMouseHook:Boolean; stdcall; export;
var
hHK : HHOOK;
implementation
function MouseHookProc(nCode: Integer;WParam: WPARAM;LParam: LPARAM): LRESULT;stdcall;
var
MouseHookStruct: ^TMOUSEHOOKSTRUCT;
nState: SHORT;
begin
Result := 0;
if nCode < 0 then
Result := CallNextHookEx(hHk,nCode,WParam,LParam)
else if wParam = WM_LBUTTONDOWN then
begin
showmessage('aa');
end;
end;

function EnableMouseHook:Boolean; stdcall; export;
begin
if hHk = 0 then
Begin
hHk := SetWindowsHookEx(WH_MOUSE,@MouseHookProc,Hinstance,0);
Result := True;
end
else
Result := False;
end;

function DisableMouseHook:Boolean; stdcall; export;
begin
if hHk <> 0 then
begin
UnHookWindowsHookEx(hHk);
hHk := 0;
Result := True;
end
else
Result := False;
end;

end.

end.



各位老大帮我看看这个Hook哪里不对呀我的思想是点击鼠标左键弹出一个对话框,但是第一次鼠标一点击弹出了许多的对话框,第二次就什么也不弹出了为什么呀
 
MouseHookProc 錯誤

當WM_LBUTTONDOWN後將不再執行CallNextHookEx

function MouseHookProc(nCode: Integer;WParam: WPARAM;LParam: LPARAM): LRESULT;stdcall;
var
MouseHookStruct: ^TMOUSEHOOKSTRUCT;
nState: SHORT;
begin
Result := 0;
if nCode < 0 then
Result := CallNextHookEx(hHk,nCode,WParam,LParam)
else if wParam = WM_LBUTTONDOWN then
begin
beep;
end;
Result := CallNextHookEx(hHk,nCode,WParam,LParam);
end;
 
不行,问题照旧
 
不能判断消息
 
怎么判断呀老大
 
后退
顶部