Solved

Stopping parent process until child has completed?

Posted on 1998-11-12
8
189 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
Comment Utility
please help me
0
 
LVL 1

Expert Comment

by:hilit
Comment Utility
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
Comment Utility
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
Comment Utility
The function is called:      system()
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:gspk
Comment Utility
no sense.......it makes
0
 
LVL 3

Accepted Solution

by:
shaig earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

744 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

12 Experts available now in Live!

Get 1:1 Help Now