Solved

Stopping parent process until child has completed?

Posted on 1998-11-12
8
193 Views
Last Modified: 2013-11-20
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).
0
Comment
Question by:gspk
8 Comments
 

Author Comment

by:gspk
ID: 1324565
please help me
0
 
LVL 1

Expert Comment

by:hilit
ID: 1324566
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
0
 
LVL 12

Expert Comment

by:migel
ID: 1324567
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...
}

0
 
LVL 3

Expert Comment

by:shaig
ID: 1324568
The function is called:      system()
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:gspk
ID: 1324569
no sense.......it makes
0
 
LVL 3

Accepted Solution

by:
shaig earned 100 total points
ID: 1324570
Yes it does (atleast to some of us).

the ::system() function documentation says:
The system function passes command to the command interpreter, which executes the string as an operating-system command.
please type         system          in your visual editor, then select the word and finally press F1 for more detailed information.
0
 
LVL 3

Expert Comment

by:shaig
ID: 1324571
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" );
}
0
 

Author Comment

by:gspk
ID: 1324572
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
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now