code from FFCal.mq4
Code extracted from FFCal.mq4 ----------------------------------- #import "wininet.dll" #define INTERNET_FLAG_PRAGMA_NOCACHE 0x00000100 // Forces the request to be resolved by the origin server, even if a cached copy exists on the proxy. #define INTERNET_FLAG_NO_CACHE_WRITE 0x04000000 // Does not add the returned entity to the cache. #define INTERNET_FLAG_RELOAD 0x80000000 // Forces a download of the requested file, object, or directory listing from the origin server, not from the cache. int InternetOpenA( 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/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)"; hSession_IEType = InternetOpenA(InternetAgent, Internet_Open_Type_Preconfig, "0", "0", 0); hSession_Direct = InternetOpenA(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) Log("hInternet: " + hInternet); if (hInternet == 0) return(false); Print("Reading URL: " + strUrl); //added by MN iResult = InternetReadFile(hInternet, sBuffer, Buffer_LEN, lReturn); if (bWinInetDebug) Log("iResult: " + iResult); if (bWinInetDebug) Log("lReturn: " + lReturn[0]); if (bWinInetDebug) Log("iResult: " + iResult); if (bWinInetDebug) Log("sBuffer: " + sBuffer); if (iResult == 0) return(false); bytes = lReturn[0]; strWebPage = StringSubstr(sBuffer, 0, lReturn[0]); // If there's more data then keep reading it into the buffer 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]); } Print("Closing URL web connection"); //added by MN iResult = InternetCloseHandle(hInternet); if (iResult == 0) return(false); return(true); } //================================================================================================= //================================================================================================= //=================================== LogUtils Functions ====================================== //================================================================================================= //================================================================================================= void OpenLog(string strName) { if (!EnableLogging) return; if (logHandle <= 0) { string strMonthPad = ""; string strDayPad = ""; if (Month() < 10) strMonthPad = "0"; if (Day() < 10) strDayPad = "0"; string strFilename = StringConcatenate(strName, "_", Year(), strMonthPad, Month(), strDayPad, Day(), "_log.txt"); logHandle = FileOpen(strFilename,FILE_CSV|FILE_READ|FILE_WRITE); Print("logHandle =================================== ", logHandle); } if (logHandle > 0) { FileFlush(logHandle); FileSeek(logHandle, 0, SEEK_END); } } void Log(string msg) { if (!EnableLogging) return; if (logHandle <= 0) return; msg = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES|TIME_SECONDS) + " " + msg; FileWrite(logHandle,msg); } //================================================================================================= //================================================================================================= //=================================== Timezone Functions ====================================== //================================================================================================= //================================================================================================= #import "kernel32.dll" int GetTimeZoneInformation(int& TZInfoArray[]); #import #define TIME_ZONE_ID_UNKNOWN 0 #define TIME_ZONE_ID_STANDARD 1 #define TIME_ZONE_ID_DAYLIGHT 2 int TZInfoArray[43]; datetime TimeGMT() { int DST = GetTimeZoneInformation(TZInfoArray); if (DST == 1) DST = 3600; else DST = 0; return( TimeLocal() + DST + (TZInfoArray[0] + TZInfoArray[42]) * 60 ); } //================================================================================================= //================================================================================================= //================================= END IMPORTED FUNCTIONS ===================================== //================================================================================================= //=================================================================================================
Hi fftremblay, your source code posted here is what I need. But when I test it, there are many errors of variable not defined: hSession_IEType, Internet_Open_Type_Preconfig,... and so on. Do I need to define these variables somewhere? Thanks.
Where can I get a copy of FFCAL.mq4?
Bill
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi everyone,
I need your help to understand something.
Why on earth when I use this file "s_wininet.mq4", I have 4 pop up asking for my authorization to use the different wininet functions and when I use FFCal.mq4, I don't have any pop up while it's using the same functions ??
Thanks for your help.