Can't get external program to run

 

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

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

 
/*
* 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
 
stringo:
Thank you - it works now
 
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 

 
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
Reason: