Download MetaTrader 5

Can't get external program to run

To add comments, please log in or register
Jerry Spence
218
Jerry Spence  

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
1215
Ilyas  
MQL5 strings are unicode, so you must use unicode version functions (ShellExecuteW)

danielth
63
danielth  
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)

Slava
Moderator
7090
Slava  
/*
* 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  
stringo:
Thank you - it works now
Eric
153
Eric  
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  
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