//**************************************************************************** // $Module type: Package // $Module name: ShellExecute // $Author : Wil van Antwerpen [W4] and Nils G. Svedmyr // Created : 1997-09-30 @ 11:46 // // Description : To be able to call the windows default program // for a specific file extention. // Example: To run the spreadsheet invent.xls it // will automatically start Excel with the invent.xls // spreadsheet running. // // Access method: DoStartDocument "Operation" "Document" "Parameters" "Path" // example: Send DoStartDocument "open" "c:\MsOffice\Excel\Example.xls" "" "" // or: Send DoStartDocument "open" "Example.xls" "" "c:\MsOffice\Excel\" // // $Rev History // 1997-09-30 Module header created // 1999-06-27 Changed to Will's new syntax. // 2000-09-11 Changed for Vdf7 by Nils G. //**************************************************************************** #IFNDEF GET_SHELLEXECUTE External_Function ShellExecute "ShellExecuteA" Shell32.Dll ; Handle hwnd ; String sOperation ; String sFile ; String sParameters ; String sDirectory ; Integer nShowCmd ; Returns VOID_TYPE #ENDIF // The defines below can be used to find out what kind of error has occured if // the API-call ShellExecute is used. Define ERROR_FILE_NOT_FOUND For 2 // The specified file was not found. Define SE_ERR_FNF For 2 // The specified file was not found. Define SE_ERR_PNF For 3 // The specified path was not found. Define ERROR_PATH_NOT_FOUND For 3 // The specified path was not found. Define SE_ERR_ACCESSDENIED For 5 // The operating system denied access to the specified file. Define SE_ERR_OOM For 8 // There was not enough memory to complete the operation. Define ERROR_BAD_FORMAT For 11 // The .exe file is invalid (non-Win32® .exe or error in .exe image). Define SE_ERR_SHARE For 26 // A sharing violation occurred. Define SE_ERR_ASSOCINCOMPLETE For 27 // The file VO association is incomplete or invalid. Define SE_ERR_DDETIMEOUT For 28 // The DDE transaction could not be completed because the request timed out. Define SE_ERR_DDEFAIL For 29 // The DDE transaction failed. Define SE_ERR_DDEBUSY For 30 // The DDE transaction could not be completed because other DDE transactions were being processed. Define SE_ERR_NOASSOC For 31 // There is no application associated with the given file VO extension. This error will also be returned if you attempt to print a file that is not printable. Define SE_ERR_DLLNOTFOUND For 32 // The specified dynamic-link library was not found. Define csERROR_FILE_NOT_FOUND For "The specified file was not found." Define csSE_ERR_FNF For "The specified file was not found." Define csSE_ERR_PNF For "The specified path was not found." Define csERROR_PATH_NOT_FOUND For "The specified path was not found." Define csSE_ERR_ACCESSDENIED For "The operating system denied access to the specified file." Define csSE_ERR_OOM For "There was not enough memory to complete the operation." Define csERROR_BAD_FORMAT For "The .exe file is invalid (non-Win32.exe or error in .exe image)." Define csSE_ERR_SHARE For "A sharing violation occurred." Define csSE_ERR_ASSOCINCOMPLETE For "The file name association is incomplete or invalid." Define csSE_ERR_DDETIMEOUT For "The DDE transaction could not be completed because the request timed out." Define csSE_ERR_DDEFAIL For "The DDE transaction failed." Define csSE_ERR_DDEBUSY For "The DDE transaction could not be completed because other DDE transactions were being processed." Define csSE_ERR_NOASSOC For "There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable." Define csSE_ERR_DLLNOTFOUND For "The specified dynamic-link library (.dll file) was not found." Procedure DDE_Error_Handler Global Integer iErrorID String sMessage Case begin Case (iErrorID = ERROR_FILE_NOT_FOUND) Append sMessage csERROR_FILE_NOT_FOUND Case Break Case (iErrorID = ERROR_PATH_NOT_FOUND) Append sMessage csERROR_PATH_NOT_FOUND Case Break Case (iErrorID = ERROR_BAD_FORMAT) Append sMessage csERROR_BAD_FORMAT Case Break Case (iErrorID = SE_ERR_ACCESSDENIED) Append sMessage csSE_ERR_ACCESSDENIED Case Break Case (iErrorID = SE_ERR_ASSOCINCOMPLETE) Append sMessage csSE_ERR_ASSOCINCOMPLETE Case Break Case (iErrorID = SE_ERR_DDEBUSY) Append sMessage csSE_ERR_DDEBUSY Case Break Case (iErrorID = SE_ERR_DDEFAIL) Append sMessage csSE_ERR_DDEFAIL Case Break Case (iErrorID = SE_ERR_DDETIMEOUT) Append sMessage csSE_ERR_DDETIMEOUT Case Break Case (iErrorID = SE_ERR_DLLNOTFOUND) Append sMessage csSE_ERR_DLLNOTFOUND Case Break Case (iErrorID = SE_ERR_NOASSOC) Append sMessage csSE_ERR_NOASSOC Case Break Case ((iErrorID = SE_ERR_OOM) OR (iErrorID = 0)) Append sMessage csSE_ERR_OOM Case Break Case (iErrorID = SE_ERR_SHARE) Append sMessage csSE_ERR_SHARE Case Break Case Else Append sMessage "Unknown DDE Error occurred.\n" Append sMessage ("Number:" * trim(iErrorID)-".") Case Break Case end Send Stop_Box sMessage End_Procedure // DDE_Error_Handler hInstance // this will perform an operation on a file (e.g. open) with the application // registered in the Windows Registry to open that type of file (via its extension) // sOperation would be "OPEN" (it could also be "PRINT" etc). Procedure DoStartDocument GLOBAL String sOperation String sDocument String sParameters String sPath Handle hInstance hWnd // remove any leading/trailing spaces in the string Move (Trim(sDocument)) To sDocument Move (Trim(sPath)) To sPath Get Window_Handle To hWnd Move (ShellExecute (hWnd, sOperation, sDocument, sParameters, sPath, SW_SHOWDEFAULT)) To hInstance If (hInstance <= 32) Begin Send DDE_Error_Handler hInstance End End_Procedure // DoStartDocument