Download MetaTrader 5
To add comments, please log in or register
The entire MQL5.community history on a single page!
Hoang Ngoc Thach
28148
Hoang Ngoc Thach 2014.01.06 10:57 

I have this simple code.

but it had problem when it load kernel32.dll.

its work very good on MT4 platform.

I have tested on WinXP and Win7.

Please tell me why.


//+------------------------------------------------------------------+
//|                                            aaaaaaaaaaaaaaaaa.mq5 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1
#import "kernel32.dll"
   bool CopyFileA(string lpExistingFileName, string lpNewFileName, bool failIfExists);
#import 

int Timecount;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---do task
   //string filename = "C:\\Users\\PC\\Desktop\\1.txt";
   //string new_filename = "C:\\Users\\PC\\Desktop\\2.txt";
   string filename = "D:\\1.txt";
   string new_filename = "D:\\2.txt";
   if(TimeLocal()-Timecount>=2){// load every 2 seconds
      Timecount=TimeLocal();
      //---copy
      CopyFileA(filename,new_filename,false);
      }
//--- return value of prev_calculated for next call
   return(rates_total);
  }

Files:
kernel32.zip 392 kb
Alain Verleyen
Moderator
30299
Alain Verleyen 2014.01.06 11:54  
rockyhoangdn:

I have this simple code.

but it had problem when it load kernel32.dll.

its work very good on MT4 platform.

I have tested on WinXP and Win7.

Please tell me why.


You can't access file outside the sandbox with mql5 (even with DLL).

For security reasons, work with files is strictly controlled in the MQL5 language. Files with which file operations are conducted using MQL5 means, cannot be outside the file sandbox.

Hoang Ngoc Thach
28148
Hoang Ngoc Thach 2014.01.06 16:44  
angevoyageur:

You can't access file outside the sandbox with mql5 (even with DLL).

Thanks.

But, is that any solution for this?

I want copy file outside by using MT5.

Alain Verleyen
Moderator
30299
Alain Verleyen 2014.01.06 16:53  
rockyhoangdn:

Thanks.

But, is that any solution for this?

I want copy file outside by using MT5.

https://www.mql5.com/en/forum/15331

Error opening the file in a specific directory
Error opening the file in a specific directory
  • www.mql5.com
Error opening the file in a specific directory.
Hoang Ngoc Thach
28148
Hoang Ngoc Thach 2014.01.06 18:14  
angevoyageur:

https://www.mql5.com/en/forum/15331

Ok.

Thanks.

/
To add comments, please log in or register