gspk
asked on
Stopping parent process until child has completed?
Iam using Winexec API to execute a dos exe for formatting disk and when i call this function that dos exe is running in a separate process(child) and parent is going to execute next stmt. but only when that child process(i.e formatting) has completed then only parent should go to next stmt. execution how to know whether child has completed execution so that i can go to next stmt.? I have seen Spawn and exec functions to run dos exe but they are not supported in Win3.11 Please help me? I want in Windows(16bit).
Can you use CreateProcess instead? If your application is win95/NT try it and then you will be able to get the process information.
Then you should use _cwait which is the function that waits until a proces is over.
Good luck
Hilit
Then you should use _cwait which is the function that waits until a proces is over.
Good luck
Hilit
Hi!
You can use IsTask() function inside message pump to determine is task runnig.
for example:
hDosTask = WinExec("Program to run", SW_SHOW);
if (hDosTask > 32)
{
while (TRUE)
{
if (IsTask(hDosTask))
{
MSG msg;
while (PeekMessage(hWnd, &msg, NULL, NULL, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else
break;
}
// continue work...
}
You can use IsTask() function inside message pump to determine is task runnig.
for example:
hDosTask = WinExec("Program to run", SW_SHOW);
if (hDosTask > 32)
{
while (TRUE)
{
if (IsTask(hDosTask))
{
MSG msg;
while (PeekMessage(hWnd, &msg, NULL, NULL, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else
break;
}
// continue work...
}
The function is called: system()
ASKER
no sense.......it makes
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If this is not enough, here is some more information from the documantatin, that is self-explanetory:
/* SYSTEM.C: This program uses
* system to TYPE its source file.
*/
#include <process.h>
void main( void )
{
system( "type system.c" );
}
/* SYSTEM.C: This program uses
* system to TYPE its source file.
*/
#include <process.h>
void main( void )
{
system( "type system.c" );
}
ASKER
See iam using it in windows if you call system it goes in to dos mode for execution ok but the function returns immediately and goes to next stmt execution in windows and the dos exe runs in the background in a separate thread we can't know whether it is completed or not i want it at any cost. In we can't use functions like spawn or execv to check whether that task is ruunning or not as thay ar not supported in win3.11 and i want in win3.11
ASKER