Windows\system目录下有一个操纵HTMLHELP的控件,叫做hhctrl.ocx 具体用法如下该OCX不需添加在部件中,只需直接声明该api
Declare Function htmlhelp Lib "hhctrl.ocx" _ Alias "HtmlHelpA" (ByVal hwnd As Long, _ ByVal lpHelpFile As String, ByVal wCommand _
As Long, ByVal dwData As Long) As Long
在VB中使用语句如下:比方form名为form1:chm文件中有一张网页名为AAA.htm
Dim m_Value As Long m_Value = htmlhelp(form1.hwnd, App.Path & "\帮助文件.chm::/AAA.htm", 0, 0)
If m_Value = 0 Then MsgBOX "无法打开帮助文件!"
End If
符号::/为相对路径
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Command1_Click()
ShellExecute Me.hwnd, "open", "C:\aa.chm", vbNullString, vbNullString, 1
End Sub