lwallace@javelin.es.com (Raptor) (03/30/91)
I'm trying to install a message hook in my application so I can filter out messages to other/all applications. Has anyone gotten this to work for them? SetWindowsHook(WH_GETMESSAGE, lpProc) and UnsetWindowsHook(WH_GETMESSAGE, lpProc). I can install it fine, and watch my hook function execute through cvw. It sure seems to be scanning all the messages. But when I decide to de-install it, I get an access violation. I've watched the ProcInstance of my hook function and it never changes, though my code and data segments are moveable. I've put a redundant FARPROC cast in the call to UnsetWindowsHook() but that doesn't help. One idiosyncracy I've noticed is, SetWindowsHook returns NULL for the address of the next hook function. The documentation doesn't say to do anything special in this case, though I can accept that nothing special needs to be done. Would code segments help anyone in their diagnosis? -- Lynn Wallace |I am not an official representative of Evans and Sutherland Computer Corp.| <- E&S. Or for that matter, unofficial. Salt Lake City, UT 84108 |Internet: lwallace@javelin.sim.es.com War not make one great! -- Yoda
jeff@cdp.UUCP (04/02/91)
One thing to be careful about with UnhookWindowsHook: for at least some hooks, calling this routine causes Windows to generate one last call to the hook routine, with the ncode parameter set to -1. You need to be prepared to handle this case: you not free the ProcInstance until UnhookWindowsHook returns, and your hook routine (when it receives this code) must call DefHookProc. Jeff Dean jeff@cdp.igc.org uunet!pyramid!cdp!jeff