[comp.windows.ms.programmer] Windows Hooks

bns@nro.cs.athabascau.ca (Chris Dollmont) (04/08/91)

I'm having a little trouble with hooks.  I understand that all of the 
hook code has to be out in a DLL.  I've written the hook, I can get it 
to work after installing it, but when I uninstall it, it sends my machine 
into BRS land.  Hard reboot time.
 
Can someone provide me with an example of a hook routine?  Please?  
Pretty Please??
 
I'm about ready to tear my hair out on this one...
 
Thanx in advance.
 
Chris

Chris Dollmont             ersys!bns@nro.cs.athabascau.ca
Edmonton Remote Systems:  Serving Northern Alberta since 1982

jeff@cdp.UUCP (04/09/91)

> I'm having a little trouble with hooks.  I understand that all of the
> hook code has to be out in a DLL.  I've written the hook, I can get it
> to work after installing it, but when I uninstall it, it sends my machine
> into BRS land.  Hard reboot time.


When you invoke UnhookWindowsHook, your hook routine may be invoked
one last time (with the first argument, nCode, set to -1).  You must
be prepared to handle this case: in particular, you must not call
FreeProcInstance until the unhook is complete; and (as mentioned in
the documentation) when you see that nCode is -1, you should invoke
DefHookProc without doing any other processing.

	Jeff Dean
	jeff@cdp.igc.org
	uunet!pyramid!cdp!jeff