I am trying to make a callback in vc++ and vb (vc++ calls a function in vb) and one of the parameters passed to the function that calls the callback is passed to the callback, it's value ignored.

this is the same functionality of the lParam in EnumFontFamilies.

The declare (in vb) for the function defines wParam of my function as type Any. This allows me to pass numbers, objects, or strings to the callback function.

Unfortunatly, my code doesn't work correctly for this. It works for numbers variables (i.e. integer and long) and it works for variants, but it doesn't work with strings (the debug window shows "?????" for the value of wParam)

Here is the c++ code:
Code:
#include <windows.h>

typedef int (__stdcall *STATUSCALLBACK)(int uCalled, int uReturn, WPARAM wParam);

int __stdcall test(STATUSCALLBACK f, WPARAM wParam)
{
	return f(123, 123, wParam);
}
here is the vb code:
VB Code:
  1. Option Explicit
  2. Declare Function test Lib "H:\Microsoft Visual Studio\MyProjects\callback\Debug\callback.dll" (ByVal cbkCallbackProc As Long, ByRef wParam As Any) As Long
  3.  
  4. Public Function CB(ByVal uCalled As Long, ByVal uReturn As Long, wParam As [b]Variant[/b]) As Long
  5.    
  6.     Debug.Print "uCalled" & vbTab & uCalled
  7.     Debug.Print "uReturn" & vbTab & uReturn
  8.     Debug.Print "wParam" & vbTab & wParam
  9.    
  10.     CB = 54321
  11. End Function
  12.  
  13. Sub main()
  14.     Dim a As [b]Variant[/b]
  15.    
  16.     a = "hello world"
  17.    
  18.     Debug.Print "Return" & vbTab & test(AddressOf CB, a)
  19. End Sub

i need to be able to put any data type, object type, or user-defined type in place of the variant type i used here