Download MetaTrader 5

Shell32.dll ShellExecuteA not working

To add comments, please log in or register
Learn operation principles of Trading Signals for MetaTrader.
mojdk 2015.02.17 20:00 


 I am totally new to MQL4, but I am learning. What I want to achieve is to execute a Python script when a certain event occur. 

I got the event and everything done, but I can't seem to get the MQL4 implementation working, so I can in fact execute it. This is the last piece in my puzzle.

So I've been Google'ing around, and it appears that you can import a shell32.dll Windows file, and use a method from there called ShellExecuteA, but I know very little about Windows programming, and neither can I get a "demo" code to work.

Can it be because I am using a 64 bit version of Windows? 

This is the code I've found:

//|                                             ShellExecuteTest.mq4 |
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                               |
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link      ""

/* ShellExecute defined in MSDN as
HINSTANCE ShellExecute(HWND hwnd, LPCTSTR lpVerb,LPCTSTR lpFile, LPCTSTR lpParameters, LPCTSTR lpDirectory,INT nShowCmd);

for detailed information.*/

//---- let's define nShowCmd values
#define SW_HIDE             0
#define SW_SHOWNORMAL       1
#define SW_NORMAL           1
#define SW_MAXIMIZE         3
#define SW_SHOW             5
#define SW_MINIMIZE         6
#define SW_SHOWNA           8
#define SW_RESTORE          9
#define SW_SHOWDEFAULT      10
#define SW_FORCEMINIMIZE    11
#define SW_MAX              11

//---- we need to define import of SHELL32 DLL
#import "shell32.dll"
//---- defining ShellExecute
/* Normally we should define ShellExecute like this:
int ShellExecuteA(int hWnd,string lpVerb,string lpFile,string lpParameters,string lpDirectory,int nCmdShow);

But, we need to keep lpVerb,lpParameters and lpDirectory as NULL pointer to this function*/
//---- So we need to define it as (look: "string" parameters defined as "int" to keep them NULL):
int ShellExecuteA(int hWnd,int lpVerb,string lpFile,int lpParameters,int lpDirectory,int nCmdShow);
//---- we need to close import definition here
//| script program start function                                    |
int start()
//---- let's do it!
Alain Verleyen
Alain Verleyen 2015.02.17 21:21  
You need to use ShellExecuteW, the unicode version.
whroeder1 2015.02.17 22:01  
To add comments, please log in or register