passing a reference to a function

 

I am in process of creating a dll. In a mql4 function I would like to pass 2 or more parameters, which will be called in a dll. And the dll function should return multiple parameters.

In this process I am passing a reference of an array resDataCollection1, which will store the data that is be returned.

Is this code correct??

MQL4 FUNCTION

double resDataCollection1[2]={0,0};

DataCollection1(para1, para2, para3, &resDataCollection1);

DLL FUNCTION

MT4_EXPFUNC double __stdcall DataCollection1(int para1, double para2, double para3, double *DataCollection1Return)

{

// do some calculation

DataCollection1Return[0]=return1;

DataCollection1Return[1]=return2;

return 0;

}

 

#import "yourdll.dll"
double DataCollection1(int para1, double para2, double para3, double &DataCollection1Return[]);
#import

and to call the function:

foobaz = DataCollection(foo, bar, baz, resDataCollection1);

The dll will receive a pointer to the first element of the array.

 
7bit:

#import "yourdll.dll"
double DataCollection1(int para1, double para2, double para3, double &DataCollection1Return[]);
#import

and to call the function:

foobaz = DataCollection(foo, bar, baz, resDataCollection1);

The dll will receive a pointer to the first element of the array.


Thanks 7bit I got it. Thank you very much
Reason: