Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to run my help file ?

Status
Not open for further replies.

Johnweida

MIS
Apr 29, 2003
91
CN
Hi,

Please kindly tell me how to run my help file(hlp.chm) by code with click event of a botton. Thanks.

John Satellite
 
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(&quot;You did not provide a filename.&quot;,&quot;AppLauch Method&quot;)
RETURN
ENDIF

IF PCOUNT() < 2
tcCmd = &quot;Open&quot;
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

DECLARE INTEGER ShellExecute ;
IN SHELL32.DLL ;
INTEGER nWinHandle,;
STRING cOperation,;
STRING cFileName,;
STRING cParameters,;
STRING cDirectory,;
INTEGER nShowWindow

* 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 + &quot; does not exist!&quot;,&quot;AppLauch Method -- AppLauch Method&quot;)
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 = &quot;Print&quot;
lnFileStatus = ShellExecute(0,&quot;&tcCmd&quot;,tcOutFile,&quot;&quot;,&quot;&quot;,0)
ELSE
lnFileStatus = ShellExecute(0,&quot;&tcCmd&quot;,tcOutFile,&quot;&quot;,&quot;&quot;,1)
ENDIF
DO CASE
CASE m.lnFileStatus > 32
* successful open
CASE m.lnFileStatus = 2
MESSAGEBOX(&quot;Bad Association (for example, invalid URL)&quot;,;
&quot;AppLauch Method -- AppLauch Method&quot;)
CASE m.lnFileStatus = 29
MESSAGEBOX(&quot;Failure to load application&quot;,&quot;AppLauch Method -- AppLauch Method&quot;)
CASE m.lnFileStatus = 30
MESSAGEBOX(&quot;Application is busy&quot;,&quot;AppLauch Method -- AppLauch Method&quot;)
CASE m.lnFileStatus = 31
MESSAGEBOX(&quot;No application association with specified &quot;+;
&quot;command: &quot; + m.tcCmd,&quot;AppLauch Method -- AppLauch Method&quot;)
OTHERWISE
MESSAGEBOX(&quot;Unknown Error&quot;,&quot;AppLauch Method -- AppLauch Method&quot;)
RETURN .F.
ENDCASE
ENDIF



Jim Osieczonek
Delta Business Group, LLC
 
Try this command:

RUN/N C:\WINDOWS\HH C:\PHLEDGER\PHLEDGER.CHM

Hope this may help you!


Bren
VFP SA - Philippines [pipe]

 
Johnweida,

jimoo's solution is very complete and well done...the code I use is very similar though shorter:

Declare Integer ShellExecute In shell32.Dll Integer hndWin, String cAction, String cFileName, String cParams, String cDir, Integer nShowWin

ShellExecute(0,&quot;open&quot;,&quot;C:\Program Files\MyHelp.chm&quot;,&quot;&quot;,&quot;&quot;,3)


...foxwizard's solution will work only if there are no spaces in the path such as &quot;\program files\&quot;. 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(&quot;C:\Program Files\MyHelp.chm&quot;)
RUN/N C:\WINDOWS\HH &lcCHMPath

********************
Function GetShortPath(pcFileName)
********************
Local lnRes, lcPath

Declare Integer GetShortPathNameA In Win32API As GetShortPathName String, String, Integer

lcPath = Replicate(Chr(32), 165) + Chr(0)
lnRes= GetShortPathName(pcFileName, @lcPath, 164)
Clear Dlls GetShortPathName
Return (Left(lcPath, lnRes))
Endfunc



Slighthaze = NULL
craig1442@mchsi.com
&quot;Whom computers would destroy, they must first drive mad.&quot; - Anon​
 
If you have the fox help engine installed, running your help file is as simple as

SET HELP TO MyHelp.chm
HELP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top