I need an array as an output parameter in a C++ function which is then called from VB6. I am using VS 2015 with C++ for the DLL project.
I couldn't find a way to create the array and return it in the C++ code (which would be the best solution), so I am trying to create a big enough array in the VB6 code and pass it as a parameter, then change it in the C++ code and use the result values in VB6 again. Below is an example with a byte array but my final function needs to be an array of structures, so solutions with string at the place of the byte array don't work.
C++ code (the call itself works):
__declspec(dllexport) void __stdcall Test(
char* data, int* len)
{
*len = 3;
data[0] = 1;
data[1] = 2;
data[2] = 3;
}
VB6 code: the code works, the length parameter is changed as expected but the data array does not change, it remains zeros:
Private Declare Sub Test Lib "MyDll.dll" (ByRef data() As Byte, length As Long)
Dim data(10) As Byte
Dim length As Long
Call Test(data, length)