🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #352

Re: Unwanted Multitasking!!

#352
From: Nick Jurascheck
Date: Mon, 13 Apr 1992 15:12
55 lines
2370 bytes
In article <1992Apr10.133656.28981@ugle.unit.no> jlongva@Siri.Unit.NO
(J|rgen Longva) writes:

> I'm writing a windos-program that must call external .exe-files during
> it's runtime. I use WinExec(...) to do this, but there is a small prob-
> lem with this method: the Windows program does not stop!
> 
> The external routine must pass data back to the windows-program, and I
> use the hard disk as a buffer:
> 
>   // Executes the external routine.
>   if (WinExec("routine.exe", SW_HIDE) < 32)
>     --> Error
> 
>   // Reads the information returned by the external routine.
>   if ((file = _open("info.txt", O_RDWR)) == -1)
>     --> Error
> 
>   ...
> 
> The problem is that the main-program continues to run - and reaches the
> line where I open the result-file too early. I've made a .pif-file for
> the externl routine that checks the "Exclusive"-flag for priority.
> 
> How can I check when the external routine is finished? Is there an al-
> ternative to WinExec(...) (the LoadModule(...) does only work for win-
> dows .exe-files)?

I have done this successfully by using FindWindow to check when
"routine.exe" has terminated.  The code (from memory) looks something like:

	WinExec("routine.exe", SW_HIDE);
	while(FindWindow(NULL, "routine.exe", ...) != NULL)
	{
		; /* Wait until routine.exe terminates... */
	}
	/* Now process the file created by routine.exe: */
	.
	.

I also tried checking for existence of the file created, but this
caused some problems with Win 3.0.

Hope this helps,
	
	Nick 

JANET: JurascheckNH@cs.bham.ac.uk  |  UUCP: ...!mcvax!bhamcs!JurascheckNH
BITNET: JurascheckNH%cs.bham.ac.uk@ukacrl.bitnet
INTERNET: JurascheckNH%cs.bham.ac.uk@cunyvm.cuny.edu
-- 
Nick			
JANET: JurascheckNH@uk.ac.bham.cs  |  UUCP: ...!mcvax!bhamcs!JurascheckNH
BITNET: JurascheckNH%cs.bham.ac.uk@ukacrl.bitnet
INTERNET: JurascheckNH%cs.bham.ac.uk@cunyvm.cuny.edu
Technical Details
Message-ID: <1992Apr13.151249.28695@cs.bham.ac.uk>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!warwick!nott-cs!bhamcs!flopsy!nhj
References: <1992Apr10.133656.28981@ugle.unit.no>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!warwick!nott-cs!bhamcs!flopsy!nhj
From: nhj@flopsy.cs.bham.ac.uk (Nick Jurascheck)
Newsgroups: comp.windows.ms.programmer,comp.windows.ms
Subject: Re: Unwanted Multitasking!!
Message-ID: <1992Apr13.151249.28695@cs.bham.ac.uk>
Date: 13 Apr 92 15:12:49 GMT
References: <1992Apr10.133656.28981@ugle.unit.no>
Sender: nhj@cs.bham.ac.uk
Organization: Birmingham University Computer Science
Lines: 55