Download MetaTrader 5
To add comments, please log in or register
Sell your applications via the Market. It is secure!
mostafalotfi
185
mostafalotfi 2014.02.28 14:27 

Dear Friends

Could you please have a look at the below and advise me why its not working in new version of MQL4?

//===================================   GrabWeb Functions   =======================================
//=================================================================================================
bool bWinInetDebug=false;
int hSession_IEType;
int hSession_Direct;
int Internet_Open_Type_Preconfig=0;
int Internet_Open_Type_Direct=1;
int Internet_Open_Type_Proxy=3;
int Buffer_LEN=13;

#import "wininet.dll"

#define INTERNET_FLAG_PRAGMA_NOCACHE  0x00000100
#define INTERNET_FLAG_NO_CACHE_WRITE  0x04000000
#define INTERNET_FLAG_RELOAD          0x80000000

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

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

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

int InternetCloseHandle(int hInet);

#import

int hSession(bool Direct)
{
   string InternetAgent;
   if(hSession_IEType==0)
   {
      InternetAgent="Mozilla/5.0 (Windows NT 5.1; rv:25.0) Gecko/20100101 Firefox/25.0";
      hSession_IEType=InternetOpenW(InternetAgent,Internet_Open_Type_Preconfig,"0","0",0);
      hSession_Direct=InternetOpenW(InternetAgent,Internet_Open_Type_Direct,"0","0",0);
   }
   if(Direct) 
   { 
      return(hSession_Direct); 
   }
   else 
   {
      return(hSession_IEType); 
   }
}

bool GrabWeb(string strUrl, string& strWebPage)
{
        int hInternet;
        int iResult;
        int lReturn[]={1};
        string sBuffer="x";
        int bytes;
        
        hInternet=InternetOpenUrlA(hSession(false),strUrl,"0",0, 
                              INTERNET_FLAG_NO_CACHE_WRITE | 
                              INTERNET_FLAG_PRAGMA_NOCACHE | 
                              INTERNET_FLAG_RELOAD,0);
        if(bWinInetDebug)
                Print(hInternet);   
        if(hInternet==0)
                return(false);

        iResult=InternetReadFile(hInternet,sBuffer,Buffer_LEN,lReturn);


        if(bWinInetDebug)
                Print(iResult);
        if(bWinInetDebug)
                Print(lReturn[0]);
        if(bWinInetDebug)
                Print(iResult);
        if(bWinInetDebug)
                Print(sBuffer);
        if(iResult == 0)
                return(false);
        bytes=lReturn[0];

        strWebPage=StringSubstr(sBuffer,0,lReturn[0]);
        
        while(lReturn[0]!=0)
        {
                iResult=InternetReadFile(hInternet,sBuffer,Buffer_LEN,lReturn);
                if(lReturn[0]==0)
                        break;
                bytes=bytes+lReturn[0];
                strWebPage=strWebPage+StringSubstr(sBuffer,0,lReturn[0]);
        }

        iResult=InternetCloseHandle(hInternet);
        if(iResult==0)
                return(false);

        return(true);
}
qjol
3243
qjol 2014.02.28 14:31  
mostafalotfi
185
mostafalotfi 2014.02.28 14:56  

i read that post but i couldn't fix it :(

Thanks Anyway,

Alain Verleyen
Moderator
28595
Alain Verleyen 2014.02.28 18:56  
mostafa:

i read that post but i couldn't fix it :(

Thanks Anyway,

Then you can create a request in Jobs Service.
/
To add comments, please log in or register