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哪里不对呀我的思想是点击鼠标左键弹出一个对话框,但是第一次鼠标一点击弹出了许多的对话框,第二次就什么也不弹出了为什么呀
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哪里不对呀我的思想是点击鼠标左键弹出一个对话框,但是第一次鼠标一点击弹出了许多的对话框,第二次就什么也不弹出了为什么呀