Download MetaTrader 5
To add comments, please log in or register
MQL5 language supports OpenCL. Try it!
Forex Alpha
33
Forex Alpha 2014.06.03 12:12 

In the older MT4 versions I could write/read CSV files and I would like to continue with that. Though after all the updates now the piece of code which I'm using doesn't work anymore.

Does anyone have an idea how to solve this issue?

 Here you can see the code which I'm using:

#import "kernel32.dll"
#define GENERIC_READ    0x80000000
#define GENERIC_WRITE   0x40000000
#define FILE_SHARE_READ                 0x00000001
#define FILE_SHARE_WRITE                0x00000002
#define FILE_SHARE_DELETE               0x00000004
#define CREATE_NEW      1
#define CREATE_ALWAYS   2
#define OPEN_EXISTING   3
#define OPEN_ALWAYS     4
#define INVALID_HANDLE -1

int CreateFileA(
      string   FileName,
      int      DesiredAccess,
      int      dwShareMode,
      int      lpSecurityAttributes,
      int      dwCreationDistribution,
      int      dwFlagsAndAttributes,
      int      hTemplateFile
);   
                    
bool WriteFile(
      int      hFile,
      string   Buffer,
      int      nNumberOfBytesToWrite,
      int     lpNumberOfBytesWritten[],
      int      lpOverlapped
);         
   
bool CloseHandle(
      int   hObject
);

bool LZSeek(
int hObject,
int Number1,
int Number2
);

int init()
  {
  start();
   return(0);
  }
int deinit()
  {
  
   return(0);
  }
int start()
  {
  WriteNewData("test"); 
  
   return(0);
  }
  
void WriteNewData(string NewMessage){
   string Location = "C:/test.CSV";  
   int hFile = CreateFileA(Location,GENERIC_WRITE,FILE_SHARE_READ,0,OPEN_ALWAYS,0,0);           
   int FileLength = StringLen(NewMessage); 
   int BytesWritten[]={0};    
   LZSeek(hFile,0,2);
   WriteFile(hFile,NewMessage,FileLength,BytesWritten,0); 
   CloseHandle(hFile);
}
/
To add comments, please log in or register