ShellExecute(NULL,"open","deal.exe","c:\\","H:\\",SW_HIDE);
我用一个循环调用这个deal.exe,怎么知道已经执行完毕?
谢谢帮助!
用createprocess()可以监视进程状态, ShellExecute () 不行
CreateProcess( NULL, // No module name (use command line).
(LPTSTR)(LPCTSTR)( cszFn1), // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parents environment block.
NULL, // Use parents starting directory.
&start, // Pointer to STARTUPINFO structure.
&proc ); // Pointer to PROCESS_INFORMATION structure.
if (WaitForSingleObject(proc.hProcess, INFINITE)
!= WAIT_FAILED)
{
// yours
}
也可以用ShellExecuteEx
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = "open";
ShExecInfo.lpFile = "deal.exe";
ShExecInfo.lpParameters = "C:\\";
ShExecInfo.lpDirectory = "E:\\";
ShExecInfo.nShow = SW_HIDE;
ShExecInfo.hInstApp = NULL;
if(ShellExecuteEx(&ShExecInfo))
{
WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
CloseHandle(ShExecInfo.hProcess);
//程序执行完了
}