Consultor Eletrônico



Kbase P16695: How to execute an external program and wait until it is fini
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   30/01/2003
Status: Unverified

GOAL:

How to execute an external program and wait until it is finished (Kernel32)

FACT(s) (Environment):

Windows

FIX:


---------------------------------Example.p--------------------------------------
{windows.i}

DEF VAR hProcess AS INTEGER NO-UNDO.

DEF VAR ReturnValue AS INTEGER NO-UNDO.

hProcess = CreateProcess("notepad.exe c:\config.sys",
"",
1).
IF hProcess=0 THEN
ShowLastError().
ELSE DO:
RUN WaitForSingleObject IN hpApi (hProcess,
-1, /* -1=INFINITE */
OUTPUT ReturnValue).
/*Very Important to Close the Handle.*/
/*If you do not Kernel32 cannot destroy the object*/
RUN CloseHandle IN hpApi (hProcess, OUTPUT ReturnValue).
END

--------------------------------------------------------------------------------