Mt4 b600 / ghttp.mqh and InternetOpenUrlA() problem (solved)

 

Good afternoon,

I have a bunch of tools making use of the ghttp.mqh library to make an http call using the following function.

However, after updating to b600, the InternetOpenUrlA() function always returns zero.

Has anybody found a solution to this?

Thanks in advance.

bool HttpGET(string strUrl, string strWebPage)
{
  int hSession = InternetOpenA(AGENT, INTERNET_OPEN_TYPE_DIRECT, "0", "0", 0);

  int hReq = InternetOpenUrlA(hSession, strUrl, "0", 0,
             INTERNET_FLAG_NO_CACHE_WRITE |
             INTERNET_FLAG_PRAGMA_NOCACHE |
             INTERNET_FLAG_RELOAD, 0);

  if (hReq == 0) {
    return(false); // False is always returned
  }

  // ... more lines of code here
}
 

See the many other cases here on the forum where one has to substitute the "A" version for "W" version of functions (Wide Unicode). In other words, "InternetOpenW" instead of "InternetOpenA".

However, since many data types have changed in the new build you will have to verify that parameters/arguments used are in agreement with the definition.

 
FMIC:

See the many other cases here on the forum where one has to substitute the "A" version for "W" version of functions (Wide Unicode). In other words, "InternetOpenW" instead of "InternetOpenA".

However, since many data types have changed in the new build you will have to verify that parameters/arguments used are in agreement with the definition.

Hi Fmic, thanks for your reply. The InternetOpenW function does not exist on the library :-(
 

You have to declare it the same way that the "A" function was declared!

It is an external WININET function in the same DLL as the "A" function!

 
FMIC:

You have to declare it the same way that the "A" function was declared!

It is an external WININET function in the same DLL as the "A" function!

Oh, right! I will and let you know.
 

OK, I have fixed it! LOL! Now I have problems with the MD5 function LOL!

Thanks a lot FMIC!

 

Hi flaab

I dont understand how did you fix the problem.

Re-Coding wininet.dll and how or something else ?

Thanks

 
jfd:

Hi flaab

I dont understand how did you fix the problem.

Re-Coding wininet.dll and how or something else ?

Thanks


Maybe there's a mismatch between the versions of WiniNet (the old one for which the ghttp.mqh library was conceived, and the new one).

If you have a number of different apps that now have crashed, then you should adapt to this new situation and try to hack the old ghttp.mqh library by updating the WiniNet calls to InternetOpen or InternetOpenUrl.

There's WiniNet API here.

 
jfd:

Hi flaab

I dont understand how did you fix the problem.

Re-Coding wininet.dll and how or something else ?

Thanks

Welcome to mql4.com forum,

Did you read this topic https://www.mql5.com/en/forum/149321. Maybe it can help you.

 
angevoyageur:

Welcome to mql4.com forum,

Did you read this topic https://www.mql5.com/en/forum/149321. Maybe it can help you.



I'm having a look now. Thks!
 

Hi and are you trying the HttpPost? i have modify the ghttp but im not able to fix it.

this are myc hanges in the import

bool InternetCanonicalizeUrlW(string lpszUrl, string lpszBuffer, int& lpdwBufferLength[], int dwFlags);

int InternetOpenW(string sAgent, int lAccessType, string sProxyName="", string sProxyBypass="", int lFlags=0);

int InternetOpenUrlW(int hInternetSession, string sUrl, string sHeaders="", int lHeadersLength=0, int lFlags=0,
   int lContext=0);

int InternetReadFile(int hFile, uchar & sBuffer[], int lNumBytesToRead, int& lNumberOfBytesRead[]);

int InternetCloseHandle(int hInet);

int InternetConnectW(int handle, string host, int port, string user, string pass, int service, int flags, int context);

bool HttpSendRequestW(int handle, string headers, int headersLen, int& optional[], int optionalLen);

bool HttpAddRequestHeadersW(int handle, string headers, int headersLen, int modifiers);

int HttpOpenRequestW(int hConnect, string lpszVerb, string lpszObjectName, string lpszVersion,
 string lpszReferer, uchar & lplpszAcceptTypes[], int dwFlags, int dwContext);

when i try to compile it im getting some warning but no errors:

 arrays passed by reference only        ghttp.mqh       140     50// HttpGet function

arrays passed by reference only ghttp.mqh       140     69// HttpGet function

truncation of constant value    ghttp.mqh       113     38 // hReq

truncation of constant value    ghttp.mqh       166     50//dwOpenRequestFlags

 truncation of constant value   ghttp.mqh       183     79 // HttpAddRequestHeadersW with he HTTP_ADDREQ_FLAG_REPLACE

and after testing in a indicator im getting error Access violation read to 0x80000200 in 'wininet.dll'

Are you trying the same or just GET?





Reason: