your import declaration is wrong. it needs to be like this:
#import "shell32.dll" int ShellExecuteA(int hWnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd); #import
do not pass 0 as verb but a real operation type. if you need to pass a null pointer pass a real null pointer. 0 as a string parameter will get converted to "0", not what you want. you get a real one with an uninitialized string, ie
string sNull; // NULL pointer as long as not initialized ShellExecuteA(..., ..., ..., sNull, sNull, 0);
evaluate the return value if it's still not working.
regards
your import declaration is wrong. it needs to be like this:
do not pass 0 as verb but a real operation type. if you need to pass a null pointer pass a real null pointer. 0 as a string parameter will get converted to "0", not what you want. you get a real one with an uninitialized string, ie
evaluate the return value if it's still not working.
regards
no - "int, int, string" allows passing NULL per forexfactory eg.
It ought to work. This works everytime -
ShellExecuteA(0,0,"notepad.exe",0,0,SW_SHOW);
might help
#include <WinUser32.mqh> #define SW_SHOW 5
ShellExecute at MSDN http://msdn.microsoft.com/en-us/library/windows/desktop/bb762153(v=vs.85).aspx
This below, is, interesting ;)
string sNull; // NULL pointer as long as not initialized
Yes, I can get the notepad call to always work. Maybe it's my batch file.
All it does is copy one file I made to another.
See attached.
I don't see attachment so I'll put it here:
copy c:\Users\OSR2\JUNK.txt c:\Users\OSR2\JUNK2.txt pause
Shell("C:\\Users\\OSR2\\EA2.bat"); Shell("cmd.exe", "/C \"C:\\Users\\OSR2\\EA2.bat\""); //////////////////////////////////////////////// #import "shell32.dll" int ShellExecuteA(int hWnd, string Verb, string File, string Parameter, string Path, int ShowCommand); #import bool Shell(string file, string parameters=""){ #define DEFDIRECTORY NULL #define OPERATION "open" // or print #define SW_HIDE 0 // http://www.metatrader4.com/forum/1476 #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 int r=ShellExecuteA(0, OPERATION, file, parameters, DEFDIRECTORY, SW_SHOWNORMAL); if (r <= 32){ Alert("Shell failed: ", r); return(false); } return(true); }
Подскажите!
Почему мне выдает ошибку при выполнении команды ShellExecuteA, номер которой 2.
Я написал следующее:
#import "C:\WINDOWS\system32\shell32.dll"
int ShellExecuteA(int hWnd,int lpVerb, string lpFile,int lpParameters,int lpDirectory,int nCmdShow);
#import
....
string NullStr = "NULL";
Print(ShellExecuteA(NULL,0,"C:\\Program Files\\GetRight\\GetRight.exe /URL: http://www.dailyfx.com/files/Calendar-03-09-2014.csv /FILE:Calendar.csv /W /O",NullStr,NullStr,5));
Может я что-то не так написал?
Ту же строку C:\Program Files\GetRight\GetRight.exe /URL: http://www.dailyfx.com/files/Calendar-03-09-2014.csv /FILE:Calendar.csv /W /O выполняю в TotaCommander.
Файл переписывается из сайта.
Hi,
I have not been able to get the notepad call to work in MQL4, either using William Roeder's Shell function:
Shell("notepad.exe");
or ShellExecuteA (or ShellExecuteW) as per mrmedia:
ShellExecuteA(0,0,"notepad.exe",0,0,5);
Is the path input the issue - should this be the full path to notepad.exe e.g.
ShellExecuteA(0,"open","C:\\WINDOWS\\system32\\notepad.exe",0,0,5);
Also, how many parameters can we supply to the .exe using ShellExecuteA?
If we wish to supply more than 1, do we pass them as a string (to be unpacked in the .exe)?
Is it possible to receive output back from the .exe?
Many thanks.
// More detail:
The top of my file looks like:
#import "shell32.dll" int ShellExecuteA(int hWnd, string Verb, string File, string Parameter, string Path, int ShowCommand); #import bool Shell(string file, string parameters=""){ #define DEFDIRECTORY NULL #define OPERATION "open" // or print #define SW_HIDE 0 // http://www.metatrader4.com/forum/1476 #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 int r=ShellExecuteA(0, OPERATION, file, parameters, DEFDIRECTORY, SW_SHOWNORMAL); if (r <= 32){ Alert("Shell failed: ", r); return(false); } return(true); }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use