Download MetaTrader 5
To add comments, please log in or register
Interested in Signals activity? Come and track!
Guillermo
75
Guillermo 2016.03.10 11:46 

Hello, I would like to print some information received form an external library.

The best thing I have gotten working so far is passing an array of chars as a parameter and modifying each position individually.

Is there a simpler solution? Like returning a string from the DLL or modifying a string passed as a parameter? (I have tried both with no luck so far).

Thank you. 

Vasyl Nosal
18225
Vasyl Nosal 2016.03.10 13:11  

no, only char

#import "con.dll"
   int ConnectToServer(char &a0[]);
#import


extern string ip_address = "123.46.4";
...
char a[];
StringToCharArray(ip_address,a);
ConnectToServer(a);
Ovo Cz
2957
Ovo Cz 2016.03.10 13:43  

Returning a string is not the best idea -  it is complicated to control memory leaks. A safe solution is passing the string as a parameter, but you have to initialize it to its max length before sending the reference to DLL.

Mind the unicode when treating strings in DLL. 

Guillermo
75
Guillermo 2016.03.10 14:09  
EDIT: Got it working, guys. I was passing an incorrect parameter to CharArrayToString... I also made the code in the DLL to iterate through all chars of a char[], don't know if it is incorrect otherwise. I will test a few more things and share my final result!
/
To add comments, please log in or register