Solved

WinExec running in parallel?

Posted on 1997-03-25
1
350 Views
Last Modified: 2013-12-03
I need to run a small DOS application in my Win 3.1 c++ program(MS c++ 1.52).  I'm using WinExec to do this.

My problem is that the line following the WinExec is an if/then statement that relies on a file that the DOS program might or might now create.  IF the DOS program created the file it does one thing, else another.

What it seems to be doing is running both my program and the DOS application in parallel(Win 3.1 definition of parallel:)).  I mean, it seems to be getting past the if/then statement before the DOS application has time to finish and write its output file.

Is there any way to stop the swapping of resources in windows so it only runs the DOS application?  So it runs lineraly?  I've tried several things including a pif file for my DOS application with priorities set to max(10000).

Thanks for any ideas!
0
Comment
Question by:mojo666
[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
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 150 total points
ID: 1334219
There is no standard way to do so. However, you can use the following code that I used it for the similar purpose. It works fine.

// You should set the PIF to allow DOS programs background running.
::WinExec("ATTRIB c:\\windows\\*.*", SW_MINIMIZE);

// wait until the DOS program ends
while (::FindWindow("tty", "ATTRIB.EXE") != NULL ||  // for Windows 95
       ::FindWindow("tty", "ATTRIB") != NULL)        // for Windows 3.x
{
    // yield the control to let DOS run
    MSG msg;
    while (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
    {
        ::TranslateMessage(&msg);
        ::DispatchMessage(&msg);
    }
}

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
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…

705 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