Solved

WinExec running in parallel?

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vb.Net Loading Word 11 103
Slow process to read Excel 15 124
Problem to packaging 1 90
Explain Unit of Work pattern 2 62
This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 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