CreateProcess function usage:
Bool CreateProcess
(
LpctstrLpapplicationname,
LptstrLpcommandline,
Lpsecurity_AttributesLpprocessattributes.
Lpsecurity_AttributesLpthreadattributes,
BoolBinherithandles,
DWORDDwcreationflags ,(Create_new_console)
LpvoidLpenvironment,
LpctstrLpcurrentdirectory,
LpstartupinfoLpstartupinfo,
Lpprocess_informationLpprocessinformation
);
The command line parameters obtained by subprocesses created using CreateProcess are as follows:
1. In the sub-process, the command line parameters represented by the third parameter of the winmain function, including the Application Path, file name, and spaces separated from the parameters, are excluded. For example
Parent process:
CreateProcess (null, "C: // test.exe-P", null, null, false, 0, null, null, & Si, & PI );
In the sub-process, the value of the lpcmdline parameter is-P. Note that no double quotation marks exist.
2. If you want to view the command line parameters through the lpcmdline parameter, when the parent process creates a child process, you need to add a space number in the subroutine and parameters. For example:
Parent process:
CreateProcess ("C: // test.exe", "-P", null, null, false, 0, null, null, & Si, & PI );
In the sub-process, the lpcmdline parameter is-P and there is no space.
3. If you want to obtain the complete command line parameters of the sub-process, call the getcommandline function. The command line parameters obtained through the getcommandline function are the complete parameters of the parent process.
CreateProcess (null, "C: // test.exe-P", null, null, false, 0, null, null, & Si, & PI );
In the sub-process, the parameter returned by getcommandline is C: // test.exe-P. Note that no double quotation marks exist.
In the following cases, call the getcommandline function to obtain the command line parameters.
4. If the first parameter of CreateProcess is null and the second parameter is a sub-application and command line parameter, the command line parameter of the sub-process is the second parameter without double quotation marks. For example:
Parent process:
CreateProcess (null, "C: // test.exe-P", null, null, false, 0, null, null, & Si, & PI );
In the sub-process, the command line parameter obtained by getcommandline is C: // test.exe-P.
5. The first parameter of CreateProcess indicates the path and file name of the sub-application. If the second parameter is null, the command line parameter of the sub-process is the first parameter with double quotation marks. For example:
Parent process:
CreateProcess ("C: // test.exe", null, false, 0, null, null, & Si, & PI );
In the sub-process, the command line parameter obtained by getcommandline is "C: // test.exe".
6. the first parameter of CreateProcess refers to the path and file name of the sub-application, and the second parameter is the parameter passed to the sub-process. The command line parameter of the sub-process is the second parameter without double quotation marks. For example:
Parent process:
CreateProcess ("C: // test.exe", "-P", null, null, false, 0, null, null, & Si, & PI );
In the sub-process, the command line parameter obtained by getcommandline is-P.
System ("") executes the DOS command
If CreateProcess is used:
Sprintf (CommandLine,
"Cmd.exe/c d: & CD sample // autodownload&sampledownloader.exe % S // download_log.txt % S // sample // 150% D ",
Fname,
Downdir,
Downdir,
N
);
CreateProcess (null, CommandLine, null, null, false, create_new_console, null, null, & Si, & PI );