running an external application from within mql5 and sending arguments to that

 

I want to be able to run an external app like : notepad.exe using ShellExecuteW() and send an argument like : c:\sample.txt to that.

I mean:

notepad.exe c:\sample.txt

 

How can I send arguments to that?

I use:

#import "shell32.dll"

 and :

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

 but these line does not work:

string myRunPath="notepad.exe c:\sample.txt";
ShellExecuteW (0,0,myRunPath,"",0,SW_SHOW);

//but these line does work(without arguments):
string myRunPath="notepad.exe";
ShellExecuteW (0,0,myRunPath,"",0,SW_SHOW);
 
sd2000sd:

I want to be able to run an external app like : notepad.exe using ShellExecuteW() and send an argument like : c:\sample.txt to that.

Note that ShellExecute lpParameters is the field for such parameters.

So just try this:

string myRunPath="notepad.exe";
string myFile="c:\\sample.txt";
ShellExecuteW(0,0,myRunPath,myFile,0,SW_SHOW);
Reason: