Tepken Vannkorn
Tepken Vannkorn

Reputation: 9713

Clicking on a button to display .CHM help file in VB.NET

I want to display a .CHM help file when clicking on a button in VB.NET. Could anyone show me code how to do this?

Private Sub cmdHelp_Click(ByVal sender As System.Objects, Byval e As System.EventArgs)Handles cmdHelp.Click
   'Please help provide some code
End Sub

Upvotes: 4

Views: 12096

Answers (4)

Ray E
Ray E

Reputation: 154

You can also use HH.EXE to display a specified topic.

In the example code replace [topicid] with the real topic id and replace [yourhelpfile.chm] with the full path and name of your .chm file

If a return value is required

Dim RetVal As Integer = Shell("HH.EXE -mapid [topicid] ms-its:[yourhelpfile.chm]", AppWinStyle.NormalFocus)

otherwise just this

Shell("HH.EXE -mapid [topicid] ms-its:[yourhelpfile.chm]", AppWinStyle.NormalFocus)

Upvotes: 0

Shrivallabh
Shrivallabh

Reputation: 2893

on Button click event write this code

Dim RetVal
RetVal = Shell("hh.exe " & App.HelpFile, vbNormalFocus)

Where hh.exe is any name App.Helpfile is your chm file name

Upvotes: 1

Hand-E-Food
Hand-E-Food

Reputation: 12794

The .NET API offers the Help class in the System.Windows.Forms namespace. Some examples:

Help.ShowHelp(ParentForm, "HelpFile.chm", HelpNavigator.TableofContents, Nothing)
Help.ShowHelp(ParentForm, "HelpFile.chm", HelpNavigator.Index, Nothing)
Help.ShowHelp(ParentForm, "HelpFile.chm", HelpNavigator.Topic, "Page.html")
Help.ShowHelp(ParentForm, "HelpFile.chm", HelpNavigator.TopicId, 123)
Help.ShowHelp(ParentForm, "HelpFile.chm", HelpNavigator.Keyword, "Keyword")

Upvotes: 9

slugster
slugster

Reputation: 49974

Doing a Process.Start with a verb of open does the trick:

Module Module1

    Sub Main()
        Dim p As New Process()
        Dim psi As New ProcessStartInfo("path to my CHM file")
        psi.Verb = "open"
        p.StartInfo = psi
        p.Start()

        Console.ReadKey()
    End Sub

End Module

Note that .chm files are heavily restricted by the OS from about WinXP SP3 (SP2?) onwards - they are considered to be a reasonble security risk, so you can't open them directly from a network or remote location. You will need to code accordingly, and expect exceptions when trying to open them.

Upvotes: 5

Related Questions