In my VC++ 6 program, I call a *.bat file with WinExec(*.bat), this batch file starts a DOS program. I want my VC++ program to pause while the DOS program runs, then continue after the DOS program ends.
Only way for to find out when child program ends is to start it directly using CreateProcess() and then use process handle to check if program is dead or alive. There is no way you can do it using WinExec().
I 've found a solution , it works but ....it's pityfull !!
so at the end of your *.bat file you insert a line like this :
mkdir test
//it creates a directory
in your c++ program you write this :
sortie=false;
while(!sortie)
{
//look if the directory test exists
z= SearchPath(NULL,"test",NULL,100,&ch,&lp);
if (z>0)
//if test exists the *.bat had finished so you can go out
//of the loop and continue the execution of the program
sortie=true;
//else *.bat is not finished yet and you wait 250 ms
Sleep(250);
}
//don't forget to destroy the directory by using
w= SearchPath(NULL,"test",NULL,100,&ch,&lp);
b= RemoveDirectory(lp);
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.