I've not connected MQL to my own C++ library, but I would guess part of your issue is here:
string About(string txt);
You might want something like an array of uchar.
See this example:
https://www.mql5.com/en/articles/364#4
- 2012.04.25
- o_o
- www.mql5.com
https://www.mql5.com/en/articles/364#4
What https://www.mql5.com/en/articles/364#4 doesn't appear to say is that there's a very strong chance that it leaks memory. In that example, libmysql.dll allocates a string buffer and passes it back as a function return value. The MQL4 code uses strcpy() and CharArrayToString() to convert it into a string which MQL4 can read. But it's unlikely that the original string memory from libmysql.dll gets freed at any point.
If - unlike the example at https://www.mql5.com/en/articles/364#4 - you control the DLL code, then it's better to use a similar but different approach. MQL4 allocates a buffer, and passes that to the DLL function. The DLL function puts its response into the buffer, rather than returning a pointer to a block of memory. In other words: the way that a Windows function such as GetSystemDirectory() works.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone,
I'm testing a custom dll that shur return a string when I call its function.
No problem while retrieving an integer, but text is represented in journal with a series of question marks.
I've tested the dll with a .net form and all is working fine.
Anyone can suggest me how to solve this issue ?
Thanks in advance.
Max.
here is the mql code (just for test the dll):
and here is the journal text I get:
2018.02.21 21:18:34.281 testdll USDCHF,H1: Risultato chiamata Prova: 42
2018.02.21 21:18:34.281 testdll USDCHF,H1: Risultato chiamata About: ????????????????
2018.02.21 21:18:34.281 testdll USDCHF,H1: Sono passati 1970.01.01 00:00:31 secondi, chiamo dll
here is the dll c++ code