Download MetaTrader 5

ShellExecuteW not work on indicator.

To add comments, please log in or register
Trinh Dat
37697
Trinh Dat  

Hi

I make an indicator use shell32.dll to open website when you click text on chart.

it work, but sometime error: Access violation read to 0x00000000

I used same code with EA and it work good, no error like above.

How to fix it ? Thanks

#property indicator_chart_window
#import "shell32.dll"
int ShellExecuteW(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd);
#import
string name ="link2";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   ObjectCreate(0,name,OBJ_LABEL,0,0,0);
   ObjectSetText(name,"http://www.mql5.com",10,"Arial",clrBlue);
   ObjectSet(name,OBJPROP_XDISTANCE,100);
   ObjectSet(name,OBJPROP_YDISTANCE,40);
//---
   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[])
  {
   return(rates_total);
  }
//+------------------------------------------------------------------+
void OnChartEvent(const int id,         // Event ID
                  const long& lparam,   // Parameter of type long event
                  const double& dparam, // Parameter of type double event
                  const string& sparam  // Parameter of type string events
                  )
{
   if(id==CHARTEVENT_OBJECT_CLICK && sparam== name )
     {
     Shell32::ShellExecuteW(0,"open","http://www.mql5.com","","",3);
     }  
}
Vladimir Karputov
Moderator
50049
Vladimir Karputov  
tuoitrecuoi:

Hi

I make an indicator use shell32.dll to open website when you click text on chart.

it work, but sometime error: Access violation read to 0x00000000

I used same code with EA and it work good, no error like above.

How to fix it ? Thanks

And if you try https://www.mql5.com/ ?
Trinh Dat
37697
Trinh Dat  
barabashkakvn:
And if you try https://www.mql5.com/ ?

Hi

Still error: Access violation read to 0x00000000.

but it work good, if i used same code on EA, only error on indicator .

Thanks

Ex Ovo Omnia
3188
Ex Ovo Omnia  
tuoitrecuoi:

Hi

Still error: Access violation read to 0x00000000.

but it work good, if i used same code on EA, only error on indicator .

Thanks

I tried with MT4, and it seems the result depends on how fast you repeat clicking. When I tried hard, I got even additional errors. No idea if it could be fixed though.

 

Trinh Dat
37697
Trinh Dat  
Ovo:

I tried with MT4, and it seems the result depends on how fast you repeat clicking. When I tried hard, I got even additional errors. No idea if it could be fixed though.


Hi

I ever used the indicator and it work very good if i make FireFox like default browser.

Only error if i used IE like default browser.

Ex Ovo Omnia
3188
Ex Ovo Omnia  
tuoitrecuoi:

Hi

I ever used the indicator and it work very good if i make FireFox like default browser.

Only error if i used IE like default browser.

That could be it. When I start notepad with your script, there is no error.
Alain Verleyen
Moderator
31186
Alain Verleyen  
tuoitrecuoi:

Hi

I ever used the indicator and it work very good if i make FireFox like default browser.

Only error if i used IE like default browser.

I don't have this issue. Windows 8.1 IE 11. MT4 Build 778.
To add comments, please log in or register