PDA

Click to See Complete Forum and Search --> : Hooks, Addins and other Bothersome Stuff


Judd
Jun 28th, 2000, 05:30 PM
Right,

I'm writing an Addin for the IDE. It needs a hook to the Project Window TreeView. I managed that, but it doesn't seem to like hooking across processes (i.e. it works fine in debug (while running in the IDE), but crashes when I build it).

MSDN says for SetWindowsHookEx:


If the dwThreadId parameter is zero or specifies the identifier of a thread created by a different process, the lpfn parameter must point to a hook procedure in a dynamic-link library (DLL). Otherwise, lpfn can point to a hook procedure in the code associated with the current process.


So I thought I'd stick my hook procedure in a C/C+ DLL. I've created one with some dummy function which I can declare, and call. I can use LoadLibrary And GetProcAddress to get the address of the procedure for the SetWindowsHookEx call.

However, what I'd really like to do is not mess about in C/C++ too much, as I don't have much of a clue at all. So is it possible to set the HookProc in my C/C++ DLL and have it call back to the VB HookProc I was using (the one that already works in debug)?

(bear in mind that a VB addin is an activex dll (I think))

Any ideas?

(Of course the best solution would be for someon to tell me that cross process hooking is possible without resorting to C/C++)