单击按钮以在 VB.NET 中显示 .CHM 帮助文件

发布于 2024-11-23 18:47:56 字数 229 浏览 2 评论 0原文

我想在单击 VB.NET 中的按钮时显示 .CHM 帮助文件。谁能告诉我代码如何做到这一点?

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

生来就爱笑 2024-11-30 18:47:56

.NET API 在System.Windows.Forms 命名空间中提供Help 类。一些例子:

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")

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")
寄离 2024-11-30 18:47:56

使用 open 动词执行 Process.Start 可以解决问题:

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

请注意,从 WinXP SP3(SP2?) 开始,.chm 文件受到操作系统的严格限制 - 它们被认为存在合理的安全风险,因此您无法直接从网络或远程位置打开它们。您需要进行相应的编码,并在尝试打开它们时预期会出现异常。

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.

想你只要分分秒秒 2024-11-30 18:47:56

在按钮单击事件上编写此代码

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

其中 hh.exe 是任意名称 App.Helpfile 是您的 chm 文件名

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

寻梦旅人 2024-11-30 18:47:56

您还可以使用 HH.EXE 显示指定的主题。

在示例代码中
[topicid] 替换为真实主题 id
并将 [yourhelpfile.chm] 替换为 .chm 文件的完整路径和名称

(如果需要返回值

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

,否则只需此值)

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

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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文