Home > Software engineering >  How to make the procedure done in winrar compression and then continue to run
How to make the procedure done in winrar compression and then continue to run

Time:10-27

 
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:

reference 1st floor zgl7903 response:
see WaitForMultipleObjectsEx the return value is how much?


The return value is WAIT_OBJECT_0 + 0

CodePudding user response:

Reference command line parameters in winrar to help the section,

CodePudding user response:

reference zhao4zhong1 reply: 3/f
reference winrar help command line parameters in the section,


Winrar program is running process is to extract the normal work, only WaitForMultipleObjectsEx didn't wait for winrar returns to finish the work

CodePudding user response:

Fyi:
 WinRAR in the case of successful operation with 0 exit code, a non-zero exit error code indicates the following: 

The code value description
0 successful operation,
1 warning, non-fatal error,
2 a fatal error,
CRC error occurred while 3 decompression,
4 try to modify a locked compressed file,
5 write error,
6 file open error,
7 error command line options,
Eight out of memory,
9 file creation error,
255 user interrupt,

CodePudding user response:

If you CreateProcess there is no problem, should Wait won't wrong ~

CodePudding user response:

refer to 6th floor VisualEleven response:
if you CreateProcess there is no problem, should Wait won't wrong ~

Will is my written code has a problem,,, createprocess the return value is 1, has been running, winrar decompression
as usual
Can I create process calls over, after winrar, not on principle, run.

CodePudding user response:

refer to 7th floor aaa6633 response:
Quote: refer to the sixth floor VisualEleven response:

If you CreateProcess there is no problem, should Wait won't wrong ~

Will is my written code has a problem,,, createprocess the return value is 1, has been running, winrar decompression
as usual
Can I create process calls after winrar is over, and, according to the truth won't run


I run in administrator mode vs2015, and then to run again, WaitForMultipleObjectsEx normal wait, why is this so,,, warrior, consult
  • Related