Passing strings to/from DLL

 

Hi there,

i'm trying to pass strings from an external DLL to MT4, with no luck. Every time the EA calls the method, MT4 just crashes.

Could someone please point me to a piece of source that exchanges strings with external DLLs or enlighten me by other means?

Here's my non-working code:

c++:

MT4_EXPFUNC void _stdcall doEchos ( std::string& s )

{

s.append("MOOO moo!");

}

MT4 Header:

#import "C:\SDev\...\...\my.dll"

void doEchos ( string& s) ;

#import

MT4 EA:

string ress="";

doEchos(ress);

Any comment?

Thanks,

Armin

 

Three steps:

1- At the top of dll place these lines:

struct MqlStr

{

int len;

char *string;

};[/PHP]

2- In the dll function use something like:

MT4_EXPFUNC long __stdcall test(MqlStr* szTest)

{

}

3- In mq4 use something like:

[PHP]string szTest[];

test(szTest);
 

thanks for pointing this out.

Working in languages with garbage collector for too long made my brain a little soft...

Best wishes,

Armin