Question : return double array in Delphi call to c++

I need to call a c++ function that returns a "double *" from Delphi.

I have the other function arguments working fine but I don't have the return double array working.  Here's the c++ function spec...  

extern "C" _declspec(dllexport) double * MyFunc(double Array1[], int arraySize, int Int1, int Int2, int Int3)

the Delphi code...

Function MyFunc( InputArray   : array of double;
                  InArraySize : integer;
                  Int1       : integer;
                  Int2       : integer;
                  Int3       : integer ) :   ???DoubleOutputArray???; stdcall; external 'MyFile.dll';

The InputArray and the OutputArray are the same length.

How do I specify OutputArray in the Delphi Function spec.

Also, if the OutputArray is a pointer, how do I access specific index values in it.

Thanks.

Answer : return double array in Delphi call to c++

@asptrader

There are two ways to free memory for result array:

1. If the dll is not yours, check all its exported functions. There must be a function to release memory.

If the dll is yours, then you can add such function yourself.

2. If the dll is yours, you can change MyFunc function to receive result array from Delphi.
Random Solutions  
 
programming4us programming4us