typedef struct _RESULTCODES { /* resc */ USHORT codeTerminate; /* Termination Code */ USHORT codeResult; /* Exit Code */ } RESULTCODES; #define INCL_DOSPROCESS USHORT rc = DosCwait(ActionCode, WaitOption, ReturnCodes, ProcessIDWord, ProcessID); USHORT ActionCode; /* Execution options */ USHORT WaitOption; /* Wait options */ PRESULTCODES ReturnCodes; /* Termination Codes (returned) */ PPID ProcessIDWord; /* Process ID (returned) */ PID ProcessID; /* Process ID of process to wait for */ USHORT rc; /* return code */
Example
This example starts a child session (the program simple.exe) and then waits for the child process's termination.
#define INCL_DOSPROCESS #define START_PROGRAM "simple.exe" CHAR LoadError[100]; PSZ Args; PSZ Envs; RESULTCODES ReturnCodes; USHORT Pid; USHORT rc; strcpy(Args, "-a2 -l"); /* Pass arguments '-a2' and '-l' */ if(!DosExecPgm(LoadError, /* Object name buffer */ sizeof(LoadError), /* Length of object name buffer */ EXEC_ASYNCRESULT, /* Asynchronous/Trace flags */ Args, /* Argument string */ Envs, /* Environment string */ &ReturnCodes, /* Termination codes */ START_PROGRAM)) /* Program file name */ rc = DosCwait(DCWA_PROCESS, /* Execution options */ DCWW_WAIT, /* Wait options */ &ReturnCodes, /* Termination codes */ &Pid, /* Process ID */ ReturnCodes.codeTerminate); /* Process ID of process to wait for */