🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.windows.ms.programmer
3 messages
3 total messages Started by J|rgen Longva Fri, 10 Apr 1992 13:36
Unwanted Multitasking!!
#282
Author: J|rgen Longva
Date: Fri, 10 Apr 1992 13:36
40 lines
1651 bytes
Hi!

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 must find a solution to this quickly, as this problem delays a whole
project.

Thanks for any help.

-- 
Regards,

J|rgen Longva <jlongva@lise.unit.no>

Student of technology
University of Trondheim
Norway.
Re: Unwanted Multitasking!!
#293
Author: Natawut Nupairoj
Date: Fri, 10 Apr 1992 18:57
32 lines
1730 bytes
In article <1992Apr10.133656.28981@ugle.unit.no>, jlongva@Siri.Unit.NO (J|rgen Longva) writes:
|> 
|> 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)?

There are 2 ways to solve this:

1. Use yield() function (proably don't work)
2. Have some synchronization ie: the external routine create a special file
   when it completes its job.  Your main program have to check this file.

Yeah, it does not look great but I think it works.

Natawut Nupairoj.
Re: Unwanted Multitasking!!
#352
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads