#import "kernel32.dll"int CreateProcessA(string lpApplicationName,
string lpCommandLine,
int lpProcessAttributes,
int lpThreadAttributes,
int bInheritHandles,
int dwCreationFlags,
int lpEnvironment,
string lpCurrentDirectory,
int & lpStartupInfo[],
int & lpProcessInformation[]);
int WaitForSingleObject(int Handle, int Timeout);
intGetLastError();
#import
int StartTerminal()
{
// Create an array to mimic a STARTUPINFO structure, which is 68 bytes long int startupinfo[17];
// Set the cb value of the STARTUPINFO structure. All the other values can// be left set to zero
startupinfo[0] = 17 * 4;
// Create an array to mimic a PROCESS_INFORMATION structure. Doesn't need// initialisationint processinfo[4];
// Call create processif (CreateProcessA("c:\\windows\\system32\\calc.exe", "c:\\windows\\system32\\calc.exe", 0, 0, 0, 0, 0, ".", startupinfo, processinfo) != 0) {
// Wait for calc.exe to be closed // Handle is in processinfo[0];
WaitForSingleObject(processinfo[0], 60 * 1000);
Print("Calc.exe started and closed...");
} else {
Print("CreateProcess() failed");
Print(kernel32::GetLastError());
}
}
(the piece of code was taken somewhere from here: https://www.mql5.com/en/forum/131239 )
returns with error code=2, which means "The system cannot find the file specified.", regardless of what to pass as application name or a command line
Most likely, the matter is in the incorrect specification of structures (STARTUPINFO, PROCESS_INFORMATION, etc.). But I do not know how to create real structure with all of these pointers, etc.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
(the piece of code was taken somewhere from here: https://www.mql5.com/en/forum/131239 )
returns with error code=2, which means "The system cannot find the file specified.", regardless of what to pass as application name or a command line
Most likely, the matter is in the incorrect specification of structures (STARTUPINFO, PROCESS_INFORMATION, etc.). But I do not know how to create real structure with all of these pointers, etc.