Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: parameters visible and correct in interpreter but not when complied


Message #1 by pr1smiley@m... on Tue, 13 Nov 2001 05:11:08
Interesting problem using out parameters w/ TLI.InvokeHookArraySub where 
an dll calls another dll.  The out parameters are visible and correct when 
the project is run in debug in the interpreter, but not when compiled.

Consider the following function in a dll "MyTestParam.clsInOut"

Public Function testParamInOut(ByRef inParam As Variant, _
  ByRef outParam As Variant)

  outParam = inParam

End Function

From another dll I want to call this function passing an [in] parameter 
and returning an [out] parameter.  This following code works in the VB 
interpreter but fails when compile, i.e., return "Empty" for the outParam.

Public Function dothis() As Variant
Dim vParam()  As Variant
Dim vArgs()   As Variant
Dim oObject   As Object
Dim iParam    As Integer
Dim iArgIndex As Integer
Dim iVT       As Integer


ReDim vParam(1)             'dim the parameter array
ReDim vArgs(UBound(vParam)) 'dim the args arrays for call invokeHook

'populate the parmeter array
vParam(0) = "test"
vParam(1) = Empty

'reverse the parameter array to the args array 
'and pass pointers (byRef parameters)
For iParam = 0 to UBound(vParam)
  
  iArgIndex = UBound(vParam) - iParam         'reverse index for args array
  vArgs(iArgIndex) = VarPtr(vParam(iParam))   'ptr to parameter array 
  iVT = VT_BYREF OR VT_VARIANT                'data type
  CopyMemory vArgs(iArgIndex), iVT, 2         
Next iParam

Set oObject = CreateObject("MyTestParam.clsInOut")

'call the function
TLI.InvokeHookArraySub oObject, "testInOut",INVOKE_FUNC, vArgs

'return the out parameter
doThis = vParam(1)

End Sub


Any ideas!

  Return to Index