I am trying to write a function in C to get around VB's system hook limitation.
To keep as much as possible in VB, I just have the hook function in the C++
dll and it calls VB. I create and destroy the hook in VB. All works OK, but
when I switch to another app and back again, the hook stops working. Any

Also, in C i am using CallWindowProcA to call my VB function. Does anyone
know the proper way to call a VB function from C. Here is some code and thanks
in advance.


In VB:

Private Declare Sub SetVBAddress Lib "TestDLL.dll" (ByVal Address As Long)
Private Declare Function KeyProcAddress Lib "TestDLL.dll" () As Long

Sub cmdStartHook
SetVBAddress AddressOf SubWndProc
HookId = SetWindowsHookEx(WH_MOUSE, KeyProcAddress, App.hInstance, 0)
End Sub

int VBHookAddress;

int code, // hook code
WPARAM wParam, // virtual-key code
LPARAM lParam // keystroke-message information
return CallWindowProcA ((WNDPROC) VBHookAddress,0,code,wParam,lParam);
//just pass it on to VB

extern "C" void _stdcall SetVBAddress(int VBAdd)
VBHookAddress =VBAdd;
//Keep the address of the VB function

extern "C" int _stdcall KeyProcAddress()
return (int)KeyboardProc;
//Return the address of KeyProc to VB