I have the following code:
The code is working fine. But after ShellExecuteW() command, I am getting a file which I have to load in OnInit(). But the execution doesn't wait for the ShellExecuteW() to complete and moves on.
Kindly, let me know how I can hold the program to complete the commandline ShellExecute and then read file and then set the Timer for further execution.
If you want to wait for the process to exit, then instead of ShellExecuteW() you should use something like
if (CreateProcessW()) WaitForSingleObject();
It takes a bit more time coding it, though.
If you want to wait for the process to exit, then instead of ShellExecuteW() you should use something like
It takes a bit more time coding it, though.
A good solution.. But I couldn't find how it can be implemented in MQl5.
jaffer wilson:
But the execution doesn't wait for the ShellExecuteW() to complete and moves on.
Kindly, let me know how I can hold the program to complete the commandline ShellExecute and then read file and then set the Timer for further execution.
After invoking ShellExecuteW(), poll (watch, wait) for the existence of the file that will be created. Do this from within your MQL code. When the file exists, continue execution in your MQL code.
Without knowing what exactly you are trying to do, and speaking off the top of my head . . .
- Use OnInit() only to fire off the ShellExecuteW() process.
- Check for the file's existence using OnTimer(), like every second.
- When the file appears, fire off a custom event to read/process/handle the file contents.
After invoking ShellExecuteW(), poll (watch, wait) for the existence of the file that will be created. Do this from within your MQL code. When the file exists, continue execution in your MQL code.
Without knowing what exactly you are trying to do, and speaking off the top of my head . . .
- Use OnInit() only to fire off the ShellExecuteW() process.
- Check for the file's existence using OnTimer(), like every second.
- When the file appears, fire off a custom event to read/process/handle the file contents.
Thank you sir for your help.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have the following code:
The code is working fine. But after ShellExecuteW() command, I am getting a file which I have to load in OnInit(). But the execution doesn't wait for the ShellExecuteW() to complete and moves on.
Kindly, let me know how I can hold the program to complete the commandline ShellExecute and then read file and then set the Timer for further execution.