* FUNCTION: Run_RunWith * Author: George Tasker * Date: January 28, 1999 - 8:59 AM * Purpose: Runs the program associated * with a file (opening the progrom). If * no association, brings up the "Open With..." * dialog * Modified January 25, 2001 - 10:25 AM * Added additional optional parameter to control the operation verb LPARAMETERS pcFilename, pnWindowState, pcOp * * pcFilename is the file to run and open * * pnWindowState (optional) is the way the window * is displayed (default it SW_SHOWNORMAL 9) * * pcOp (optional) the operation to execute (open, edit, or print) * Return value is the instance handle or error * code LOCAL lcFilename, lnWindowState, lnargs,; lnresult, lcparms, lcop, lcpath, lcbuffer,; lnsize, lcrundll lnargs = PCOUNT() IF lnargs >= 2 IF VARTYPE(lnWindowState) = 'N' lnWindowState = pnWindowState ELSE lnWindowState = 9 && SW_SHOWNORMAL ENDIF ELSE lnWindowState = 9 && SW_SHOWNORMAL ENDIF IF lnargs = 3 lcop = pcOp ELSE lcop = 'open' ENDIF lcFilename = pcFilename lcparms = "" lcpath = JUSTPATH(lcFilename) DECLARE INTEGER ShellExecute IN Shell32; INTEGER hWnd, STRING @lpOperation,; STRING @lpFile, STRING @lpParameters,; STRING @lpDirectory, INTEGER nShowCmd lnresult = ShellExecute(0, @lcop, @lcFilename,; @lcparms, @lcpath, lnWindowState) IF lnresult < 33 && Error occurred IF lnresult = 31 && No file associated DECLARE INTEGER GetSystemDirectory IN Win32API; STRING @lpBuffer, INTEGER nSize lnsize = 260 lcbuffer = SPACE(lnsize) lnsize = GetSystemDirectory(@lcbuffer, lnsize) IF lnsize > 0 lcbuffer = LEFT(lcbuffer, lnsize) lcrundll = "RUNDLL32.EXE" lcparms = "shell32.dll,OpenAs_RunDLL " lnresult = ShellExecute(0, @lcop, lcrundll,; lcparms + lcFilename, lcbuffer, lnWindowState) ENDIF ENDIF ENDIF RETURN lnresultI haven't tested it on a file without an associated editor, so...