>>>********************************************************************
>>>* Description.......: LaunchAppAndWait
>>>* Calling Samples...:
>>>* Parameter List....:
>>>* Created by........: Ed Rauh
>>>* Modified by.......:
>>>********************************************************************
>>>FUNCTION LaunchAppAndWait
>>>LPARAMETERS tcCommandLine, tuFromDir, tcWindowMode
>>>
>>>* tcCommandLine (R) - command line to launch
>>>* tuFromDir (O) - Run from directory (default - CWD)
>>>* tcWindowMode (O) - Start Application Window mode, one of (HIDE, MIN, MAX, NOR)
>>>* (default - default setting of application)
>>>
>>>* Returns:
>>>* 0 = CreateProcess didn't start what was asked
>>>* 1 = Process ran to completion
>>>* -1= Process started but user aborted wait. Danger - app is still running AFAIK
>>>
>>>#DEFINE cnINFINITE 0xFFFFFFFF
>>>#DEFINE cnHalfASecond 500 && milliseconds
>>>#DEFINE cnTimedOut 0x0102
>>>
>>>* We need some API calls, declare here
>>>
>
>Remove These to the LoadDlls method:
>
>>>* GetCurrentProcess() returns the pseudohandle of the current process
>>>DECLARE INTEGER GetCurrentProcess IN WIN32API AS GetCurrProc
>>>
>>>* WaitForIdleInput() waits until the target process is idle for input
>>>DECLARE INTEGER WaitForInputIdle IN WIN32API AS WaitInpIdle ;
>>> INTEGER nProcessHandle, ;
>>> INTEGER nWaitForDuration
>>>
>>>* WaitForSingleObject() waits until the handle in parm 1 is signalled
>>>* or the timeout period expires
>>>DECLARE INTEGER WaitForSingleObject IN WIN32API AS WaitOnAppExit ;
>>> INTEGER hProcessHandle, ;
>>> INTEGER dwTimeOut
>>>
>>>* This API call does the work. The parameters are as follows:
>>>* lpszModuleName - ptr-> file name of module to execute. Since we aren't launching .CPLs, do not use
>>>* lpszCommandLine - ptr-> command to execute, as passed to us
>>>* lpSecurityAttributesProcess - ptr-> SECURITY_ATTRIBUTES structure for Process. Pass a null pointer
>>>* lpSecurityAttributesThread - ptr-> SECURITY_ATTRIBUTES structure for first thread. Pass a null pointer
>>>* bInheritHandles - whether or not chlid inherits parent handles. Since no SECURITY_ATTRIBUTES passed, default to FALSE
>>>* dwCreateFlags - Process Creation Mode flag set. We use the default mode at normal priority, ie 0
>>>* lpvEnvironment - ptr-> a set of environment strings as if a MULTI_SZ. We don't set, so pass a null pointer
>>>* lpszStartupDir - ptr-> the starting directory. If none provided to us, pass a null pointer
>>>* lpStartInfo - ptr-> a STARTUPINFO structure. We use one structure member at times.
>>>* lpProcessInfo - ptr-> a PROCESS_INFORMATION structure, used to return PID/PHANDLE detail.
>>>* We use one member on return
>>>DECLARE SHORT CreateProcess IN WIN32API AS CrPr ;
>>> STRING lpszModuleName, ;
>>> STRING @lpszCommandLine, ;
>>> STRING lpSecurityAttributesProcess, ;
>>> STRING lpSecurityAttributesThread, ;
>>> SHORT bInheritHandles, ;
>>> INTEGER dwCreateFlags, ;
>>> STRING lpvEnvironment, ;
>>> STRING lpszStartupDir, ;
>>> STRING @lpStartInfo, ;
>>> STRING @lpProcessInfo
>>>
>>>IF TYPE('tcCommandLine') # 'C'
>>>
>>> * Command line must be a character string
>>> RETURN 0
>>>
>>>ENDIF
>>>IF TYPE('tuFromDir') # 'C'
>>>
>>> * If not a character string, pass a null pointer, defaulting to Current Working Dir
>
>IF ! THIS.lLoadedDLLs
> THIS.LoadDlls()
>ENDIF