I have a generic MTS Object Tester app (yes, this relates to a question I asked a couple of days ago) which needs to be able to call any method of an object without having preknowledge of the object's interface.
I am successfuly using the InvokeHookArray method from TLBINF32 with simple variable types, passed ByRef, like strings, integers, longs, etc. What I am having trouble with is passing a Variant array ByRef.
Some code I found from the TlbInf32 help files looks something like this:
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Declare Function VarPtrArray Lib "msvbvm60.dll" Alias "VarPtr" _
(Ptr() As Any) As Long
Dim obj As Object
Dim args() As Variant
Dim i As Integer
Dim iArr() As Integer
Dim vt As Integer
Dim InvokeID As Long
'Call Foo(i As Integer, iArr() As Integer)
'Use this code only with variable sized arrays.
args(0) = VarPtrArray(iArr)
vt = VT_BYREF Or VT_ARRAY Or VT_I2
CopyMemory args(0), vt, 2
args(1) = VarPtr(i)
vt = VT_BYREF Or VT_I2
CopyMemory args(1), vt, 2
TLI.InvokeHookArray obj, "Foo", INVOKE_FUNC, args
Like I said, this works fine for simple types, anybody have any ideas on how to use this to pass a variant array?