You should be able to use the ShellExecute. Try this example. Also, there are some FAQs on the ShellExecute and I believe ramani's web-page (you can get it from one of his posting) has some information (I believe) on it.
* be sure to include directory structure if file is not in current path.
appLaunch("hlp.chm"
***********************************************************************
FUNCTION appLaunch
PARAMETER tcOutFile,tcCmd
IF PCOUNT() < 1
MESSAGEBOX("You did not provide a filename.","AppLauch Method"
RETURN
ENDIF
IF PCOUNT() < 2
tcCmd = "Open"
ENDIF
tcCmd = PROPER(m.tcCmd)
* This code was originally located in Ken Levy's DBF2XML program so blame
* Ken for the bugs
* API Call to communicate with an application based on the registered
* file-type.
* For example:
* On my computer txt is notepad; DOC is word
* tip: to determine commands available for each filetype
* Launch explorer
* go to View / Folder Options
* Select the File Type Tag
* go to the item you wish to look up (example Acrobat)
* Press Edit
* You will see acrobat has Open, Print, and Printto option types.
IF !FILE(tcOutFile)
MESSAGEBOX(tcOutFile + " does not exist!","AppLauch Method -- AppLauch Method"
ELSE
* play with this.
* by adding the ,0 instead of ,1 I was able to get it to
* print directly without opening the document on my sceen.
* this is handy if you wish to print a pdf, word document,
* spreadsheet, text file, etc. from within your applicaiton.
IF m.tcCmd = "Print"
lnFileStatus = ShellExecute(0,"&tcCmd",tcOutFile,"","",0)
ELSE
lnFileStatus = ShellExecute(0,"&tcCmd",tcOutFile,"","",1)
ENDIF
DO CASE
CASE m.lnFileStatus > 32
* successful open
CASE m.lnFileStatus = 2
MESSAGEBOX("Bad Association (for example, invalid URL)",;
"AppLauch Method -- AppLauch Method"
CASE m.lnFileStatus = 29
MESSAGEBOX("Failure to load application","AppLauch Method -- AppLauch Method"
CASE m.lnFileStatus = 30
MESSAGEBOX("Application is busy","AppLauch Method -- AppLauch Method"
CASE m.lnFileStatus = 31
MESSAGEBOX("No application association with specified "+;
"command: " + m.tcCmd,"AppLauch Method -- AppLauch Method"
OTHERWISE
MESSAGEBOX("Unknown Error","AppLauch Method -- AppLauch Method"
RETURN .F.
ENDCASE
ENDIF
...foxwizard's solution will work only if there are no spaces in the path such as "\program files\". In order to use foxwizard's solution reliably you would either have to know for sure that no spaces existed or use the DOS short path to the HTML helpfile (.chm)...this would require something like...
Local lcCHMPath
lcCHMPath = GetShortPath("C:\Program Files\MyHelp.chm"
RUN/N C:\WINDOWS\HH &lcCHMPath
********************
Function GetShortPath(pcFileName)
********************
Local lnRes, lcPath
Declare Integer GetShortPathNameA In Win32API As GetShortPathName String, String, Integer
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.