Solved

WinExec running in parallel?

Posted on 1997-03-25
1
328 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
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

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

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

16 Experts available now in Live!

Get 1:1 Help Now