Download MetaTrader 5
To add comments, please log in or register
Sign up to publish an article and receive 200 USD
Boguslaw Nejmanowski
546
Boguslaw Nejmanowski 2014.02.25 09:33 

Hello!

I get a problem with kernel32.dll that indicator was working im MT4 <600 and now it is not. Why? What do I have to change to make it working again?

<Please use the SRC button to insert code>

//+------------------------------------------------------------------+
 //| 10.mq4 |
 //| Copyright 2014, MetaQuotes Software Corp. |
 //| https://www.mql5.com |
 //+------------------------------------------------------------------+
 #property copyright "Copyright 2014, MetaQuotes Software Corp."
 #property link "https://www.mql5.com"
 #property version "1.00"
 #property strict
 #property indicator_chart_window

 #import "kernel32.dll"
 int WinExec(string NameEx, int dwFlags);
 #import

 //+------------------------------------------------------------------+
 //| 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[])
 {
 //---
 WinExec("C:\Program Files\GetRight\GetRight.exe"+" /URL:"+"http://www.dailyfx.com/files/Calendar-02-23-2014.csv"+" /FILE:Calendar-02-23-2014.csv /W /O",0);

 //--- return value of prev_calculated for next call
 return(rates_total);
 }
 //+------------------------------------------------------------------+
 //| Timer function |
 //+------------------------------------------------------------------+
 void OnTimer()
 {
 //---

 }
 //+------------------------------------------------------------------+
 //| ChartEvent function |
 //+------------------------------------------------------------------+
 void OnChartEvent(const int id,
 const long &lparam,
 const double &dparam,
 const string &sparam)
 {
 //---

 }
 //+------------------------------------------------------------------+


Thank you for your help.


Boogie

Ubzen
Moderator
5394
Ubzen 2014.02.25 10:25  
gchrmt4
356
gchrmt4 2014.02.25 10:29  
Boogie:

I get a problem with kernel32.dll that indicator was working im MT4 <600 and now it is not. Why? What do I have to change to make it working again?

You can't use WinExec because (a) MQL4 now uses Unicode strings, and (b) there is no Unicode version of WinExec because it is a legacy function from 16-bit Windows (i.e. from the early 1990s).

You need to use something like ShellExecuteW instead, e.g. https://www.mql5.com/en/forum/149820

Boguslaw Nejmanowski
546
Boguslaw Nejmanowski 2014.02.25 19:16  

Thanks.

But how to force GetRight to download that file

WinExec("C:\Program Files\GetRight\GetRight.exe"+" /URL:"+"http://www.dailyfx.com/files/Calendar-02-23-2014.csv"+" /FILE:Calendar-02-23-2014.csv /W /O",0);
whroeder1
13602
whroeder1 2014.02.25 19:37  
Boogie: But how to force GetRight to download that file
  1. What part of "You can't use WinExec because ... there is no Unicode version of WinExec " was unclear?

    What part of "You need to use something like ShellExecuteW instead" was unclear?


  2. This is invalid.
    "C:\Program Files\GetRight\GetRight.exe"
    Backslash is the quote character
    "C:\\Program Files\\GetRight\\GetRight.exe"
qjol
3243
qjol 2014.02.25 19:39  
Boogie:

Thanks.

But how to force GetRight to download that file


what part "use something like ShellExecuteW instead" u dont understand ?
/
To add comments, please log in or register