>Function ExecShell(tcFileName, tcParams, tcDir, tnShow, tcOperation, tnHWnd) >LOCAL lnRetVal, lnParams > >lnParams = PCount() >lnRetVal = 0 > >IF lnParams < 6 > tnHWnd = 0 && no parent window >ENDIF >IF lnParams < 5 > tcOperation = 'open' && default command to 'open application' >ENDIF >IF lnParams < 4 && default window to 'normal' > tnShow = 5 >ENDIF >IF lnParams < 3 > tcDir = '' && do not chage current directory >ENDIF >IF lnParams < 2 > tcParams = '' && there are no parameters for the program to run >ENDIF > >IF !EMPTY(tcFileName) && no file to run? Do nothing. > * declare the shellexecute function to launch app > DECLARE INTEGER ShellExecute in shell32.dll ; > INTEGER hwnd, STRING @lpOperation, STRING @lpFile, STRING @lpParam, ; > STRING @lpDir, INTEGER nShowCmd > > DO CASE > CASE EMPTY(tcDir) AND EMPTY(tcParams) && don't change dir and no parameters > lnRetVal = ShellExecute(tnHWnd, @tcOperation, @tcFileName, .NULL., .NULL., tnShow) > > CASE EMPTY(tcDir) AND !EMPTY(tcParams) && don't change dir, but there are parameters > lnRetVal = ShellExecute(tnHWnd, @tcOperation, @tcFileName, @tcParams, .NULL., tnShow) > > CASE EMPTY(tcParams) AND !EMPTY(tcDir) && no parameters, change directory > lnRetVal = ShellExecute(tnHWnd, @tcOperation, @tcFileName, .NULL., @tcDir, tnShow) > > OTHERWISE > lnRetVal = ShellExecute(tnHWnd, @tcOperation, @tcFileName, @tcParams, @tcDir, tnShow) > > ENDCASE >ENDIF > >RETURN lnRetVal >>