Problems with string in DLL and WinHttpClient

 

Hi,

i try to send a string from mql to dll and work with them...

Code in MQL:

#import "myDLL.dll"

bool SetString(string foo);

#import//+-------------------------------------------------------+int start() {

string foo = "bar";

SetString(foo);

}[/CODE]

Code in DLL (taken from http://www.codeproject.com/Articles/66625/A-Fully-Featured-Windows-HTTP-Wrapper-in-C)

[CODE]bool SetString(string foo) {

// Set URL.

WinHttpClient client(L"http://myurl.de/script.php");

// Set post data.

string data = "foo="+foo;

client.SetAdditionalDataToSend((BYTE *)data.c_str(), data.size());

// Set request headers.

wchar_t szSize[50] = L"";

swprintf_s(szSize, L"%d", data.size());

wstring headers = L"Content-Length: ";

headers += szSize;

headers += L"\r\nContent-Type: application/x-www-form-urlencoded\r\n";

client.SetAdditionalRequestHeaders(headers);

// Send HTTP post request.

client.SendHttpRequest(L"POST");

wstring httpResponseHeader = client.GetResponseHeader();

wstring httpResponseContent = client.GetResponseContent();

}

Now, I use Wireshark to monitor my HTTP Traffic and the DLL send onlyhttp://myurl.de/script.php?foo=without the variable.

What's wrong in the code. I tried several ways to transfer the string to DLL...

 

No Idea? No hint?

 

In a "simple" C like manner (without using objects and without operators overloading) you can not concatenate strings with "+". So string data = "foo="+foo; will not result in what you expected. use strcat() or some similar function for that

fx_maddin:
No Idea? No hint?
 

I don't got any error while compiling. I'm, not sure if the data is availble inside the dll. How can I clarify, if this code works:

stringfoo ="bar"; SetString(foo);