How to pass an array (by reference, in VB6) to the C \ C ++ * .dll subroutine?

I need to pass an empty array of options to a DLL written in C (and available for all versions of Windows), and the C code (which I cannot control and cannot edit) will populate the empty array of options using its some return values.

Basically, when I try to do this - the ByRef array is always empty when it should contain the function / subtitle results (if I do the same in .NET, it works).

I think I need to make a custom declaration so that VB knows how to call the C function, or?

This is how the C. sub-function is declared. Given this, what do I need to do so that C can use my empty array correctly and am returning the results?

HRESULT InvokeAction(
  [in]       BSTR bstrActionName,
  [in]       VARIANT varInActionArgs,
  [in, out]  VARIANT *pvarOutActionArgs,
  [in, out]  VARIANT *pvarRetVal
);

: http://msdn.microsoft.com/en-us/library/aa382237(VS.85).aspx

+3
1

http://msdn.microsoft.com/en-us/library/aa381230(VS.85).aspx:

Dim returnVal
Dim outArgs(1)
Dim args(1)
args(0) = 3
returnVal = service.InvokeAction("GetTrackInfo", args, outArgs)
'return Val now contains the track length
'and outArgs(0) contains the track title
Dim emptyArgs(0)
returnVal = service.InvokeAction("Play", emptyArgs, emptyArgs)
'returnVal indicates if the action was successful

, , , .

+3

Source: https://habr.com/ru/post/1771771/


All Articles