How can we achieve such a call, other exe?
CodePudding user response:
Start from the command line you have compiled exe files, in the back with the incoming parameters, or the process of creating apis to use win32 provided start your program, the incoming parameters you needCodePudding user response:
//argv. CPP: Defines the entry point for the console application.
//
# include "stdafx. H"
H # include "Windows."
#include
#include
Int main (int arg c, char * argv [])
{
Printf (" % s \ n ", argv [0]).
TCHAR exe [0 x200];
_tcscpy (exe, argv [0]);
STARTUPINFO si;
PROCESS_INFORMATION PI;
ZeroMemory (& amp; Si, sizeof (si));
Si. Cb=sizeof (si);
Si. DwFlags |=STARTF_USESHOWWINDOW;
Si. WShowWindow=SW_SHOWDEFAULT;
ZeroMemory (& amp; PI, sizeof (PI));
if( ! CreateProcess (exe,//No module name (use the command line).
_T (" \ r \ n - I -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "),//the Command line.
NULL,//Process handle not inheritable.
NULL,//the Thread handle not inheritable.
FALSE,//Set the handle inheritance to FALSE.
0,//No creation flags.
NULL,//Use the parent 's environment block.
NULL,//Use the parent 's starting directory.
& Si,//Pointer to STARTUPINFO structure.
& PI)//Pointer to PROCESS_INFORMATION structure.
)
{
Update//AfxMessageBox (_T (" failure "));
return 0;
}
return 0;
}
Tried to call themselves, called argv [0], preach anything,