Download MetaTrader 5

How to download a file using URLDownloadToFileW function of Urlmon.dll ?

To add comments, please log in or register
Register as a seller and start offering your signals!
KoT 009
44107
KoT 009 2014.02.24 12:00 
i tried , but errors access violation.

#import "wininet.dll"

int InternetAttemptConnect(int x);

  int InternetOpenA(string, int, string, string, int);
   int InternetConnectA(int, string, int, string, string, int, int, int); 
   int HttpOpenRequestA(int, string, string, int, string, int, string, int); 
   int InternetOpenUrlA(int, string, string, int, int, int);
     int InternetReadFile(int, string, int, int& OneInt[]);
int InternetOpenW(string &sAgent,int lAccessType,string &sProxyName,string &sProxyBypass,int lFlags);
int InternetConnectW(int hInternet,string &szServerName,int nServerPort,string &lpszUsername,string &lpszPassword,int dwService,int dwFlags,int dwContext);
int HttpOpenRequestW(int hConnect,string &Verb,string &ObjectName,string &Version,string &Referer,string &AcceptTypes,uint dwFlags,int dwContext);
int HttpSendRequestW(int hRequest,string &lpszHeaders,int dwHeadersLength,uchar &lpOptional[],int dwOptionalLength);
int HttpQueryInfoW(int hRequest,int dwInfoLevel,int &lpvBuffer[],int &lpdwBufferLength,int &lpdwIndex);
//int InternetReadFile(int hFile,uchar &sBuffer[],int lNumBytesToRead,int &lNumberOfBytesRead);
int InternetCloseHandle(int hInet);


#import
#import "Urlmon.dll"
int URLDownloadToFileW(int pCaller,string szURL,string szFileName,int dwReserved,int Callback);
#import
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
  
  int HttpOpen = InternetOpenA("HTTP_Client_Sample", 0, "", "", 0); 
   int HttpConnect = InternetConnectA(HttpOpen, "", 80, "", "", 3, 0, 1); 
   int HttpRequest = InternetOpenUrlA(HttpOpen, "http://mql4.com", NULL, 0, 0, 0);
//---
    string URLDownloadableFile, RootFileDestination;
      int hCaller, hCallback;
      
      hCaller=0x00000000;
      URLDownloadableFile="http://www.forexfactory.com"; 
      RootFileDestination="C:\mal.html"; 
      hCallback=0x00000000;
 
      URLDownloadToFileW(hCaller,URLDownloadableFile,RootFileDestination,0,hCallback);
  }
//+------------------------------------------------------------------+
Alain Verleyen
Moderator
30737
Alain Verleyen 2014.02.24 12:01  
To add comments, please log in or register