You can't use functions such as _lopen() in v600 (or, at least, not easily). You need to use newer Win32 functions instead. See https://www.mql5.com/en/forum/147939 for a related question
gchrmt4:
You can't use functions such as _lopen() in v600 (or, at least, not easily). You need to use newer Win32 functions instead. See https://www.mql5.com/en/forum/147939 for a related question
You can't use functions such as _lopen() in v600 (or, at least, not easily). You need to use newer Win32 functions instead. See https://www.mql5.com/en/forum/147939 for a related question
Can you give me a example how i can read the file into a string with the new Win32 functions? I can open also a job if you want and pay for your help. I need just the functions to read the file into a string and give this string back.
Replacement ReadFile() function as follows. But you don't need this to read files from MT4's own directory (MQL4\Files); you can use the built-in file functions for that.
Note that this is unreliable:
ReadFile("C:\Program Files\MetaTrader4\MQL4\Files\a.txt");
You should use this instead, for the reasons set out in https://www.mql5.com/en/forum/147939
ReadFile("C:\\Program Files\\MetaTrader4\\MQL4\\Files\\a.txt");
#import "kernel32.dll" int CreateFileW(string, uint, int, int, int, int, int); int GetFileSize(int, int); int ReadFile(int, uchar&[], int, int&[], int); int CloseHandle(int); #import string ReadFile(string Filename) { string strFileContents = ""; int h = CreateFileW(Filename, 0x80000000 /*GENERIC_READ*/, 3 /*SHARE READ|WRITE*/, 0, 3 /*OPEN_EXISTING*/, 0, 0); if (h == -1) { // Open failed } else { int sz = GetFileSize(h, 0); if (sz > 0) { uchar buffer[]; ArrayResize(buffer, sz); int read[1]; ReadFile(h, buffer, sz, read, 0); if (read[0] == sz) { strFileContents = CharArrayToString(buffer, 0, read[0]); } else { // Read failed } } else { // Empty file } CloseHandle(h); } return strFileContents; }
Thank you very much.
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
Hello,
i have a ReadFile Function which does not work any more in the new build 600, can somebody help me or is there another new example for ReadFile function?
Here is the Code from my Current Read File function: