Download MetaTrader 5

Can't get external program to run

To add comments, please log in or register
Why to sell products in MetaTrader AppStore? Find that out from the article!
Jerry Spence
216
Jerry Spence 2010.05.12 02:40 

In MT4 this worked OK:


#import "shell32.dll"

int ShellExecuteA(int hWnd,int lpVerb,string lpFile,string lpParameters,int lpDirectory,int nCmdShow);

#import


void OnTick()

{

 ShellExecuteA (0,0,"Notepad.exe","",0,SW_SHOW);

}

When debugging it goes through the ShellExecute command with no error message but I don't get Notepad come up

-Jerry

Ilyas
1206
Ilyas 2010.05.12 10:09  
MQL5 strings are unicode, so you must use unicode version functions (ShellExecuteW)

danielth
63
danielth 2010.05.12 11:53  
mql5:
MQL5 strings are unicode, so you must use unicode version functions (ShellExecuteW)

Hello,

I tried to compile the same code but I get an error message as follows :

'SW_SHOW' - undeclared identifier

 Any help appreciated (I use Vista)

Slawa
Moderator
6840
Slawa 2010.05.12 13:49  
/*
* ShowWindow() Commands
*/
#define SW_HIDE             0
#define SW_SHOWNORMAL       1
#define SW_NORMAL           1
#define SW_SHOWMINIMIZED    2
#define SW_SHOWMAXIMIZED    3
#define SW_MAXIMIZE         3
#define SW_SHOWNOACTIVATE   4
#define SW_SHOW             5
#define SW_MINIMIZE         6
#define SW_SHOWMINNOACTIVE  7
#define SW_SHOWNA           8
#define SW_RESTORE          9
#define SW_SHOWDEFAULT      10
#define SW_FORCEMINIMIZE    11
#define SW_MAX              11
danielth
63
danielth 2010.05.12 15:56  
stringo:
Thank you - it works now
Eric
153
Eric 2010.05.12 20:51  
danielth:
Thank you - it works now

can somebody show the right code because i dont get what you mean by unicode...

and i cant find any example of this situation in help.

thank you 

danielth
63
danielth 2010.05.13 01:44  
Gachette:

can somebody show the right code because i dont get what you mean by unicode...

and i cant find any example of this situation in help.

thank you 

Here it is :

#property copyright "2009, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
#import "shell32.dll"
int ShellExecuteW(int hWnd,int lpVerb,string lpFile,string lpParameters,string lpDirectory,int nCmdShow);
#import
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()  // or OnTick() or OnCalculate(..)
  {
  ShellExecuteW(0,0,"notepad.exe","","c:\\windows\\system32\\",1); 
  }
//+------------------------------------------------------------------+

Automated Trading and Strategy Testing
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
To add comments, please log in or register