Void readfile (cstring filename) // path for storing the EXE file in the filename path file. Multiple EXE files can be started at a time.
{
// Tchar szbuf [1024];
File * pfile = fopen (filename, "R"); // open the file
Exesl = 0;
Int I = 0, n = 0;
Char Buf [1024];
While (! Feof (pfile ))
{
Fgets (BUF, 1024, pfile); // read a row (including the carriage return at the end of the row) to the Buf
N = strlen (BUF );
If (BUF [n-1] = '\ n') // remove the last line and press Enter.
Buf [n-1] = '\ 0 ';
Strcpy (A [I], Buf); // each row is stored in the corresponding string array.
// Afxmessagebox (A [I]);
I ++;
}
Exesl = I;
// Getdlgitem (idc_send)-> setwindowtext (szbuf); // write control
Fclose (pfile); // close the file
}
Void openexe ()
{
Int I;
For (I = 0; I <exesl; I ++)
{
// Open the specified application file
// Afxmessagebox (A [I]);
Startupinfo Si = {sizeof (SI )};
Process_information PI;
Si. dwflags = startf_useshowwindow; // specify that the wshowwindow member is valid.
Si. wshowwindow = true; // if this member is set to true, the main window of the new process is displayed.
Bool Bret = CreateProcess (
Null, // The Name Of The executable file is not specified here
A [I], // command line parameters
Null, // default process security
Null, // default process security
False, // specifies that the current process handle cannot be inherited by the quilt Process
Create_new_console, // create a new console window for the new process
Null, // use the environment variable of this Process
Null, // use the drive and directory of the current process
& Si,
& PI );
If (BRET)
{
// Disable unused handles.
Closehandle (PI. hthread );
Closehandle (PI. hprocess );
Exeid [I] = pi. dwprocessid;
}
}
}