BOOL isStartSuccess;
LPTSTR * commandArray=new LPTSTR [2];
CommandArray [0]=_tcsdup (TEXT (" C: \ \ Program Files \ \ WinRAR \ \ WinRAR exe a - s - the m5 - ibck - ep1 - r - s \ "D: \ \ ZdKRX rar " \ "D: \ \ ZdKRX " "));
CommandArray [1]=_tcsdup (TEXT (" C: \ \ Program Files \ \ WinRAR \ \ WinRAR exe a - s - the m5 - ibck - ep1 - r - s \ "D: \ \ ZdSFE rar " \ "D: \ \ ZdSFE " "));
PROCESS_INFORMATION * pidInfo=new PROCESS_INFORMATION [2];
For (int I=0; i <2; I + +)
{
ZeroMemory (& amp; PidInfo [I], sizeof (PROCESS_INFORMATION));
}
StartInfo STARTUPINFO *=new STARTUPINFO [2];
For (int I=0; i <2; I++)
{
ZeroMemory (& amp; StartInfo [I], sizeof (STARTUPINFO));
}
HANDLE * handles=new HANDLE [2];
For (int I=0; i <2; I++)
{
StartInfo [I]. Cb=sizeof (startInfo);
StartInfo [I] lpReserved=nullptr;
StartInfo [I] lpReserved2=nullptr;
StartInfo [I] lpTitle=nullptr;
StartInfo [I] lpDesktop=nullptr;
StartInfo [I] dwFlags=STARTF_USESTDHANDLES;
StartInfo [I] hStdInput=GetStdHandle (STD_INPUT_HANDLE);
StartInfo [I] hStdOutput=GetStdHandle (STD_OUTPUT_HANDLE);
StartInfo [I] hStdError=GetStdHandle (STD_ERROR_HANDLE);
IsStartSuccess=CreateProcess (nullptr, commandArray [I], nullptr, nullptr, FALSE, CREATE_NO_WINDOW, nullptr, nullptr, & amp; StartInfo [I], & amp; PidInfo [I]);
If (isStartSuccess==FALSE)
{
cout <"Create WinRar Process Failed" & lt;Int ret=GetLastError ();
cout <"The Error Code:" & lt;}
Handles [I]=pidInfo [I] hProcess;
}
WaitForMultipleObjectsEx (2, handles, TRUE, INFINITE, FALSE);
//why don't the waitformultiobjectsex effect
For (int I=0; i <2; I++)
{
The CloseHandle (pidInfo [I] hThread);
The CloseHandle (pidInfo [I] hProcess);
}
The delete [] commandArray;
The delete [] pidInfo;
The delete [] startInfo;
The delete [] handles;
Small white consult with/why don't waitformultiobjectsex effect, is returned to the winrar is still in work
CodePudding user response:
See WaitForMultipleObjectsEx the return value is how much?CodePudding user response: