SHELLEXECUTEINFO ShExecInfo;
ZeroMemory (& amp; ShExecInfo, sizeof (SHELLEXECUTEINFO));//before use best to empty
ShExecInfo. CbSize=sizeof (SHELLEXECUTEINFO);
ShExecInfo. FMask=SEE_MASK_NOCLOSEPROCESS;
ShExecInfo. The HWND=this - & gt; M_hWnd;
ShExecInfo. LpVerb=_T (" open ");
//input to invoke the exe file path
ShExecInfo. LpFile=_T (" C://lix2win//dist//test_sequance_wwz//test_sequance_wwz exe ");
//incoming command line parameter data
ShExecInfo. LpParameters=_T (" NULL ");//if no command line arguments, can be NULL
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- exe files in the current directory (negligible) -- -- -- -- -- -- -- -- -- -- -- -- -- --
//get the current program path
//TCHAR exeFullPath [200].
//GetModuleFileName (NULL, exeFullPath, 100);
////the program run the current path
//TCHAR drive [100], dir [100], fname [100], ext [20].
//_wsplitpath (exeFullPath, drive, dir, fname, ext);
//cstrings dirPath;
//dirPath. The Format (_T (" % s % s "), drive, dir);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
ShExecInfo. LpDirectory=NULL;//exe directory can be ignored here, write to NULL
ShExecInfo. NShow=SW_HIDE;//here is set to not show exe interface, if set to SW_SHOW, it can display the exe interface
ShExecInfo. HInstApp=NULL;
//call the exe program
ShellExecuteEx (& amp; ShExecInfo);
//close the exe program
If (ShExecInfo hProcess!=NULL)
{
//wait program runs out
WaitForSingleObject (ShExecInfo hProcess, INFINITE);
//close the program
The TerminateProcess (ShExecInfo. HProcess, 0);
ShExecInfo. HProcess=NULL;
}
This is button binding code, the shellexecute method is used to open a wrapper exe, don't move a muscle when running the whole interface have to waiting for the end of the run, could you tell me how to solve this situation
CodePudding user response:
You, isn't about waiting for the program runs out?WaitForSingleObject (ShExecInfo hProcess, INFINITE);
CodePudding user response:
//wait program runs outWaitForSingleObject (ShExecInfo hProcess, INFINITE);
Infinite wait ah,
Make a thread to execute the program,
CodePudding user response:
Wait in the UI thread can only be stopped responding, another thread to handle, and then place the results to inform the UI threadCodePudding user response:
The