问题
I have been trying to hook to CWnd::Create method. I tried to hook using SetWindowsHookEx api. But this is not working consistently. So, I have followed the following blog http://www.codeproject.com/Articles/49319/Easy-way-to-set-up-global-API-hooks and tried to hook to CreateWindowEx api.
Here, I am not sure whether CreateWindowEx will be called from Cwnd::Create API.
Can we hook to Cwnd::Create procedure using MHOOK? If so hooking to CreatWindowEx is the right api to listen to Cwnd::Create calls?
回答1:
Please go through this link http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/e71f690a-00de-4032-95e2-21660e2235f6/setwindowshookex-on-windows-7
Not all keyboard and mouse hooks are marshalled, only globals. And marshaling of hook is performed by thread message queue. So, thread that installs hook MUST call message pumping method.
来源:https://stackoverflow.com/questions/18246601/global-hooking-to-cwndcreate-using-mhook