Running external programs on Progress 8.2

Running external programs on Progress 8.2

Post by S.L. Prinslo » Tue, 21 Oct 1997 04:00:00



I'm using the following code to call external programs from within
Progress:

RUN WinExec ( INPUT <program-name> , INPUT 1 ).  /* 1=normal 2=minimized */

PROCEDURE WinExec EXTERNAL "kernel32.dll": /* Run Windows application */
    DEFINE INPUT PARAMETER prog_name AS CHARACTER.
    DEFINE INPUT PARAMETER prog_style AS SHORT.
END PROCEDURE.

It could also be done with
DOS <program-name>.

Windows run the program, (with the kernel32 call or the DOS call) but in
the mean time, progress continues immediately.

Is there any way I can tell progress to wait untill the called program
terminates?
In our old DOS systems progress must wait, since there is no multitasking,
but in Windows 95 it tries to access files wich are not yet created, since
Windows is still busy to start the needed application.

Most of the time I promt the user to indicate when the task is completed,
but now I have a situation where the user does not interact with the called
program, which also runs minimized and terminate after the operation. On
slower machines, or when users multitask intensively, it also happen the
users respond to the prompt before the needed aplication has even started!

Thanks
Simon

 
 
 

Running external programs on Progress 8.2

Post by Michael Ruesweg-Gilber » Wed, 22 Oct 1997 04:00:00


Hi Simon,

you told, that your externally started process runs iconized without any
user-interaction.

In that situation it is better in windows to call your external process
as a DLL fucntion, because it runs in the same thread as your Progress
process does and not asynchronous.

If you can't change your external program to a windows DLL, you will
have to make your Progress program wait for the termination of the
started process:

1. WinExec returns the process-id of the started process in it's
return-parameter (you skipped it in your function declaration - it is
legal when > 31)

2. Wait in a loop for some while and question periodically for existence
of your process-id. If you can't find it any more, the process has
terminated and you can leave your loop.

3. Use the Kerner32 API-functions for step 2
    CreateToolhelp32Snapshot
    Process32First
    Process32Next
    CloseHandle
    fr scanning for running processes.

by

M.Rsweg-Gilbert
mrz
Kaufring AG
Dsseldorf
Germany