how do i Detect if an external program has finished excuting(shellexec)?
-
I want to execute several external programs in a que. I have to execute one program and wait for it to finish and excute another. Is there a way to detect if a external running program has finished? Thanks
-
I want to execute several external programs in a que. I have to execute one program and wait for it to finish and excute another. Is there a way to detect if a external running program has finished? Thanks
Now this might sound way off because I don't know what you're trying to do, but you could write a batch file "somefile.bat" and there you can put the names of your programs. I don't know if you're familiar with batch files so for example to execute notepad, paint, and minesweeper one after the other you could just write c:\windows\notepad c:\windows\paint c:\windows\winmine paint won't start until notepad closes and so on. So you can just try to execute this batch file from your program and you won't have to worry about the checking them (unless you want the opposite). // Afterall, I realized that even my comment lines have bugs When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
-
I want to execute several external programs in a que. I have to execute one program and wait for it to finish and excute another. Is there a way to detect if a external running program has finished? Thanks
Use CreateProcess instead of
ShellExecute
, and useWaitForSingleObject
like this :// Init structs for process STARTUPINFO lpsi; lpsi.cb=sizeof(STARTUPINFO); lpsi.cbReserved2=0; lpsi.lpReserved2=0; lpsi.lpReserved=0; lpsi.lpDesktop=NULL; lpsi.lpTitle="Doing something ..."; lpsi.dwFlags=STARTF\_USESHOWWINDOW; lpsi.wShowWindow=SW\_SHOWMAXIMIZED; PROCESS\_INFORMATION lppi; if (CreateProcess(NULL,(LPTSTR)path.operator LPCTSTR), NULL, NULL, FALSE, NORMAL\_PRIORITY\_CLASS, NULL, m\_TotalCompPath.operator LPCTSTR(),&lpsi,&lppi)==0) // Error launching else { WaitForSingleObject(lppi.hProcess,INFINITE); }
~RaGE();
-
I want to execute several external programs in a que. I have to execute one program and wait for it to finish and excute another. Is there a way to detect if a external running program has finished? Thanks