Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pause VC++ program until called program with WinExec( ) terminates

Status
Not open for further replies.

lacroixja

Programmer
Nov 5, 2001
1
CA
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);

good luck !!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top