Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Parent Process Interaction with child process

Posted on 1998-11-12
5
Medium Priority
?
297 Views
Last Modified: 2013-12-29
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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 

Author Comment

by:gspk
ID: 1804913
Actually i have called format.com inside a turbo c program for formatting a disk. In a particular dialog when user clicks a button
labeled format then i call this turbo exe file so it goes to dos mode from windows until it formats the disk and i want to take next action in the program only when entire formatting is completein that turbo c exe but the problem is as soon as i call this exe with winexec it is running separately and the program is going to next stmt. but i want next stmt. to be executed based on that turbo c programs  outputi.e whether floppy formatted or not? Problem is that it is running separartely,but  i want to stop parent program from going to next stmt. until formatting is completed in that called dos exe i.e it has to complete execution. because next stmt. is based on that dos exe output.
ex:-
UINTi; i=WinExec("vsres.exe",SW_SHOWMAXIMIZED);
if(vsres.exe has completed)// i.e formatting of floppy completed
    copy files to floppy disk;

0
 
LVL 12

Expert Comment

by:mark2150
ID: 1804914
Only way to work around this one that I know of is to spawn a batch file that deletes a semaphore file when it finishes it's run.

Say you code creates the file immediately prior to firing the task, then the batch file deletes the file after the FORMAT task is complete. In this way your parent can watch for the semaphore file to disappear. I use FILELEN() to give an error when the file disappers In VB you code something like:

ON ERROR GOTO ISDONE
Retry:
X = FILELEN( semaphore )
DoEvents
GOTO RETRY
' =========
ISDONE:
RESUME ISDONE1
'
ISDONE1:
.
This is ugly but does work.

M
0
 

Author Comment

by:gspk
ID: 1804915
i want in mfc ie..vc++1.5 in win3.11
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1804916
Technique shown will work on any version of OS. Converting *five* lines to c++ shouldn't be hard - of those five lines two are error trap!

M

0
 
LVL 27

Accepted Solution

by:
BigRat earned 200 total points
ID: 1804917
The reason why WinExec returns as soon as the program has been launched is that under 16-bit Windows you must always be ready to release control so that another process can run. Although in this particular case the program is a DOS program and the process switching takes place at the DOS level, Windows must first create and maintain the DOS box in which the process it to run.
   A consequence of this is that sitting in a loop waiting for some file to pop up is also not the best user friendly way to do this. The correct way is for a notification to occur when the DOS program has finished. Mark2150 suggests that you create a file of a well known name in a well known place or location and loop wait for it to appear. This is about the best technique which is available to you, except that I would create a timer object and test for the existance of the file when the timer message occurs. Here I can count the number of (say 1 second messages) and if it exceeds some fixed value (10 mins) ask the user via a messagebox whether things are still ok. You must delete the file before launching the program and after it appears.
    You should reject this answer with a comment asking Mark2150 to pick up the points.
   have ratitude!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

610 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