It got off the ground, and now error 87 is showing up instead of the wrong url. And this is even worse :) Got it in WinHttpConnect. What can I fix? Or is absi2unicode function wrong?
#import "Winhttp.dll"int WinHttpOpen(string pwszUserAgent, int dwAccessType,
string pwszProxyName, string pwszProxyBypass, int dwFlags);
int WinHttpConnect(int hSession, /*string*/int& pswzServerName[], int nServerPort, int dwReserved);
#import "ntdll.dll"int RtlGetLastWin32Error();
int RtlSetLastWin32Error(int dwErrCode);
#import
start()
{
int hSession=WinHttpOpen("MqlHttp", 0, "", "", 0);
Print("hSession="+hSession);
string aHost="www.mql4.com";
RtlSetLastWin32Error(0); //сбрасываем последний код ошибкиint wHost[100]; int n=ansi2unicode(aHost, wHost);
int hConnect=WinHttpConnect(hSession, wHost, 80, 0);
if (hConnect<=0) Print("-Err create Connect "+RtlGetLastWin32Error());
}
// функция преобразования строки в массив//--------------------------------------------------------------- ansi2unicodeint ansi2unicode(string str, int &arr[])
{
int max=ArraySize(arr); int pos=0, i=0, x;
bool f=false;
for (x=0; i<max; f=!f, pos++) // пока есть место в массиве
{
int c=StringGetChar(str, pos); if (c==0) break; // конец строкиif (!f) x=c; else { i++; arr[i]=x+(c<<16); } // собираем символы в пары и складываем в массив
}
if (i>=max) { x=0; i=max-1; } elseif(!f) x=0; // терминирующий ноль
i++; arr[i]=x;
return(i);
}
It got off the ground, and now instead of an invalid url, error 87 is showing up. And this is even worse :) Got it in WinHttpConnect. What can I fix? Or is absi2unicode function wrong?
Attached to this post is an archive with a text document. I don't know if it helps you in any way, but take a look anyway - it's a small document. It does talk about encoding of Russian fonts, but maybe the content of the document will give you some idea. You know C++, unlike me.
it got off the ground, and now instead of the wrong url, error 87 pops up. This is even worse :) Came up in WinHttpConnect, of course. What can I fix? Or is absi2unicode function wrong ?
It's better to use standard API functions for conversion.
Here's a sample code:
#import "kernel32.dll"int MultiByteToWideChar(int CodePage, int dwFlags, string lpMultiByteStr, int cbMultiByte, int& lpWideCharStr[], int cchWideChar);
#import "Winhttp.dll"int WinHttpOpen(int pwszUserAgent[], int dwAccessType, string pwszProxyName, string pwszProxyBypass, int dwFlags);
int WinHttpConnect(int hSession, int pswzServerName[], int nServerPort, int dwReserved);
int WinHttpCloseHandle(int hInternet);
#importvoid start()
{
int lpWideCharStr[];
L("MqlHttp", lpWideCharStr);
int hInternet = WinHttpOpen(lpWideCharStr, 0, "", "", 0);
if (hInternet > 0)
{
L("www.mql4.com", lpWideCharStr);
int hConnect = WinHttpConnect(hInternet, lpWideCharStr, 80, 0);
if (hConnect > 0)
{
WinHttpCloseHandle(hConnect);
}
WinHttpCloseHandle(hInternet);
}
}
int L(string lpMultiByteStr, int& lpWideCharStr[])
{
int cchWideChar = MultiByteToWideChar(0, 0, lpMultiByteStr, -1, lpWideCharStr, 0);
ArrayResize(lpWideCharStr, 1 + cchWideChar / 2);
MultiByteToWideChar(0, 0, lpMultiByteStr, -1, lpWideCharStr, cchWideChar);
return (cchWideChar);
}
// Re-reads saved POST data byte-to-byte from file in the pseudo-character array// we need to send with HttpSendRequestA. This is due to the fact I know no clean// way to cast strings _plus_ binary file contents to a character array in MQL.// If you know how to do it properly feel free to contact me.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
This might be silly, but... Have you tried adding HTTP:// to the URL?
continue to struggle with unicode.
It got off the ground, and now error 87 is showing up instead of the wrong url. And this is even worse :)
Got it in WinHttpConnect. What can I fix? Or is absi2unicode function wrong?
continue to struggle with unicode.
It got off the ground, and now instead of an invalid url, error 87 is showing up. And this is even worse :)
Got it in WinHttpConnect. What can I fix? Or is absi2unicode function wrong?
Attached to this post is an archive with a text document. I don't know if it helps you in any way, but take a look anyway - it's a small document. It does talk about encoding of Russian fonts, but maybe the content of the document will give you some idea. You know C++, unlike me.
See how it's done here.
seems to be wrong. Can you rewrite it in MQL yourself?
continue to struggle with unicode.
it got off the ground, and now instead of the wrong url, error 87 pops up. This is even worse :)
Came up in WinHttpConnect, of course. What can I fix? Or is absi2unicode function wrong ?
It's better to use standard API functions for conversion.
Here's a sample code:
It's done via wininet.dll, so I can...
Watch it carefully from this point:
Watch carefully there from this point: