Download MetaTrader 5
To add comments, please log in or register
Share your program via Code Base. Gain access to millions of traders!
JPS1
239
JPS1 2014.04.09 05:35 

This worked and still works with an item compiled under build 616.

If I copy and paste, then recompile under build 625, web page(s) never return a string.

I don't want to assume this is build 625 because it could be my code even though the 616 version still works.

Could someone take a look and see if my code is missing something I have overlooked, or could test yourself and see if similar problem?

I would be very grateful! Thanks

#import  "Wininet.dll"
   int InternetOpenW(string, int, string, string, int);
   int InternetConnectW(int, string, int, string, string, int, int, int); 
   int HttpOpenRequestW(int, string, string, int, string, int, string, int); 
   int InternetOpenUrlW(int, string, string, int, int, int);
   int InternetReadFile(int, string, int, int& OneInt[]);
   int InternetCloseHandle(int); 
#import
 
int init()
{
   string URL= "http://google.com"; /// or web site of choice

   int HttpOpen = InternetOpenW(" ", 0, " "," ",0 ); 
   int HttpConnect = InternetConnectW(HttpOpen, "", 80, "", "", 3, 0, 1); 
   int HttpRequest = InternetOpenUrlW(HttpOpen,URL, NULL, 0, 0, 0);
   
   int read[1];
   string Buffer = " ";
   string str = "";  
 
   while (true)

   {
      InternetReadFile(HttpRequest, Buffer, StringLen(Buffer), read);
      if (read[0] > 0) str  = str  + StringSubstr(Buffer, 0, read[0]);
      else break;

   }
     
   if (HttpRequest > 0) InternetCloseHandle(HttpRequest); 
   if (HttpConnect > 0) InternetCloseHandle(HttpConnect); 
   if (HttpOpen > 0) InternetCloseHandle(HttpOpen);  
     MessageBox(str , "HTTP READ:" );     //  show the result via message box
     Print("printed string = ",str );
     InternetCloseHandle(1); 

   return(0);
}



qjol
3243
qjol 2014.04.09 08:12  
have a look here
JPS1
239
JPS1 2014.04.09 08:48  
Thank you qjol !!
/
To add comments, please log in or register