我用 1. m_hControlHook = ::SetWindowsHookEx(WH_CALLWNDPROC, WinControlHookEx_Zi,
AfxGetApp()->m_hInstance, ::GetCurrentThreadId());2. m_hControlHook = ::SetWindowsHookEx(WH_CALLWNDPROC, WinControlHookEx_Zi,
0, ::GetCurrentThreadId());3. m_hControlHook = ::SetWindowsHookEx(WH_CALLWNDPROC, WinControlHookEx_Zi,
AfxGetApp()->m_hInstance, ::GetCurrentPrcessId());// 其中 WinControlHookEx_Zi是用钩子函数!1、2、3在exe 中和dll中都钩不到用CreateThread();创建的线程里面的消息,我该怎么做呢?
AfxGetApp()->m_hInstance, ::GetCurrentThreadId());2. m_hControlHook = ::SetWindowsHookEx(WH_CALLWNDPROC, WinControlHookEx_Zi,
0, ::GetCurrentThreadId());3. m_hControlHook = ::SetWindowsHookEx(WH_CALLWNDPROC, WinControlHookEx_Zi,
AfxGetApp()->m_hInstance, ::GetCurrentPrcessId());// 其中 WinControlHookEx_Zi是用钩子函数!1、2、3在exe 中和dll中都钩不到用CreateThread();创建的线程里面的消息,我该怎么做呢?
解决方案 »
- getlasterror为什么不能够获取错误信息呢?
- 100分请教一个简单程序的崩溃问题(附源码,演示录像及说明)
- 怎么实现给另一个程序中的某个窗口发送一个鼠标双击的消息?在线等待啊~~~~
- 有一个小项目,有兴趣的请留下E_MAIL
- 有直接读取硬盘扇区的函数吗?第一个回答100分!
- 怎样删除硬盘上指定的bmp文件和事先开辟的用户缓存区里的数据????
- 线程能否一直运行?
- 如何保存ListCtrl里的内容?
- installshield 6.22中,已经封闭了控件注册,那我如何提示用户当前控件正在注册呢?如何获知?
- 关于 WM_CHAR 消息的问题
- 纯散分!!!!!!!!!
- 静态链接DLL出现异常.
::SetWindowsHookEx(WH_CALLWNDPROC, WinControlHookEx_Zi,
AfxGetApp()->m_hInstance, dwThreadID/*这个市你要挂钩的线程ID,而不是用进程ID*/);
You can install a hook procedure by calling the SetWindowsHookEx function and specifying the type of hook calling the procedure, whether the procedure should be associated with all threads in the same desktop as the calling thread or with a particular thread, and a pointer to the procedure entry point. You must place a global hook procedure in a dynamic-link library (DLL) separate from the application installing the hook procedure. The installing application must have the handle to the DLL module before it can install the hook procedure. To retrieve a handle to the DLL module, call the LoadLibrary function with the name of the DLL. After you have obtained the handle, you can call the GetProcAddress function to retrieve a pointer to the hook procedure. Finally, use SetWindowsHookEx to install the hook procedure address in the appropriate hook chain. SetWindowsHookEx passes the module handle, a pointer to the hook-procedure entry point, and 0 for the thread identifier, indicating that the hook procedure should be associated with all threads in the same desktop as the calling thread. This sequence is shown in the following example. HOOKPROC hkprcSysMsg;
static HINSTANCE hinstDLL;
static HHOOK hhookSysMsg;
hinstDLL = LoadLibrary((LPCTSTR) "c:\\windows\\sysmsg.dll");
hkprcSysMsg = (HOOKPROC)GetProcAddress(hinstDLL, "SysMessageProc");
hhookSysMsg = SetWindowsHookEx(WH_SYSMSGFILTER,hkprcSysMsg,hinstDLL,0);
You can release a thread-specific hook procedure (remove its address from the hook chain) by calling the UnhookWindowsHookEx function, specifying the handle to the hook procedure to release. Release a hook procedure as soon as your application no longer needs it. You can release a global hook procedure by using UnhookWindowsHookEx, but this function does not free the DLL containing the hook procedure. This is because global hook procedures are called in the process context of every application in the desktop, causing an implicit call to the LoadLibrary function for all of those processes. Because a call to the FreeLibrary function cannot be made for another process, there is then no way to free the DLL. The system eventually frees the DLL after all processes explicitly linked to the DLL have either terminated or called FreeLibrary and all processes that called the hook procedure have resumed processing outside the DLL. An alternative method for installing a global hook procedure is to provide an installation function in the DLL, along with the hook procedure. With this method, the installing application does not need the handle to the DLL module. By linking with the DLL, the application gains access to the installation function. The installation function can supply the DLL module handle and other details in the call to SetWindowsHookEx. The DLL can also contain a function that releases the global hook procedure; the application can call this hook-releasing function when terminating.
我只想钩到当前进程的消息!---------------------我是搂主、