Download MetaTrader 5

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

To add comments, please log in or register
Point Zero
793
Point Zero 2014.02.10 18:37 

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
}
Fernando Carreiro
2289
Fernando Carreiro 2014.02.10 18:44  

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.

Point Zero
793
Point Zero 2014.02.10 18:47  
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 :-(
Fernando Carreiro
2289
Fernando Carreiro 2014.02.10 18:50  

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!

Point Zero
793
Point Zero 2014.02.10 18:51  
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.
Point Zero
793
Point Zero 2014.02.10 19:28  

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

Thanks a lot FMIC!

DAUTRY
3
DAUTRY 2014.02.11 14:55  

Hi flaab

I dont understand how did you fix the problem.

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

Thanks

Jordi Bassaganas
3532
Jordi Bassaganas 2014.02.11 15:35  
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.

Alain Verleyen
Moderator
31094
Alain Verleyen 2014.02.11 16:26  
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.

Jordi Bassaganas
3532
Jordi Bassaganas 2014.02.11 17:35  
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!
reivaj117
61
reivaj117 2014.02.12 08:47  

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?





To add comments, please log in or register