?
Solved

WinExec running in parallel?

Posted on 1997-03-25
1
Medium Priority
?
353 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 450 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

800 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