首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

小弟我安装的鼠标全局钩子为什么不管用

2014-01-03 
我安装的鼠标全局钩子为什么不管用?钩子代码如下LRESULT CALLBACK GetMsgProc( int code, WPARAM wParam,

我安装的鼠标全局钩子为什么不管用?
钩子代码如下


LRESULT CALLBACK GetMsgProc( int code, WPARAM wParam, LPARAM lParam )     
{  
    LRESULT returnValue = CallNextHookEx( hHook, code, wParam, lParam ); 

    return returnValue;



安装代码如下

BOOL WINAPI InstallHook( BOOL IsHook, DWORD dwThreadId )     
{     
if(IsHook)     
{   
hHook=SetWindowsHookEx( WH_MOUSE_LL , (HOOKPROC)GetMsgProc, hmodDll, dwThreadId ); 
}     
return ( hHook != NULL ) ? TRUE : FALSE;
}   


整个过程没有报错,但是钩子安了以后鼠标就不动了,为什么?我在钩子里不是把消息传下去了吗??为什么不管用呢?求高人解答 VC++???鼠标全局钩子??
[解决办法]
引用:
钩子代码如下

LRESULT CALLBACK GetMsgProc( int code, WPARAM wParam, LPARAM lParam )     
{  
    LRESULT returnValue = CallNextHookEx( hHook, code, wParam, lParam ); 

    return returnValue;



安装代码如下

BOOL WINAPI InstallHook( BOOL IsHook, DWORD dwThreadId )     
{     
if(IsHook)     
{   
hHook=SetWindowsHookEx( WH_MOUSE_LL , (HOOKPROC)GetMsgProc, hmodDll, dwThreadId ); 
}     
return ( hHook != NULL ) ? TRUE : FALSE;
}   


整个过程没有报错,但是钩子安了以后鼠标就不动了,为什么?我在钩子里不是把消息传下去了吗??为什么不管用呢?求高人解答


最后一个参数改成 0 试试

hMod [in]
Type: HINSTANCE
A handle to the DLL containing the hook procedure pointed to by the lpfn parameter. The hMod parameter must be set to NULL if the dwThreadId parameter specifies a thread created by the current process and if the hook procedure is within the code associated with the current process.

热点排行