'Create a new project, Form1 is created by default. Add a few controls to the
'form.
'Add a module to the project, and add the following constants to the declarat
'ion section of the module:
Public Const HH_HELP_CONTEXT = &HF
Public Const MYHELP_FILE = "myfile.chm"
'NOTE: "myfile.chm" is the path and name of the HTML Help file (.chm) you created earlier.
'Add the following HTML Help API declaration to the module:
Public Declare Function HtmlHelpLongArg Lib "hhctrl.ocx" _
Alias "HtmlHelpA" (ByVal hwndCaller As Long, _
ByVal pszFile As String, ByVal uCommand As Long, _
ByVal dwData As Long) As Long
'Intercept the form's KeyUp method to capture the F1 key using the following
'sample code in the Form KeyUp event procedure:
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
dim iRetCode As Long
If KeyCode = vbKeyF1 Then
iRetCode = HtmlHelpLongArg(Me.ActiveControl.hWnd, _
MYHELP_FILE,HH_HELP_CONTEXT,Me.ActiveControl.HelpContextID)
'------------------
'or this
iRetCode = HtmlHelpLongArg(Me.hWnd,MYHELP_FILE,0,0)
'---------------------
End If
End Sub
'Set the form's KeyPreview, WhatsThisHelp, and WhatsThisButton properties to TRUE.
'Set the HelpContextID property of each control on the form to a value from the help project file's MAP section.
方法二:
Public Declare Function WinHelp Lib "user32" Alias "WinHelpA" (ByVal hwnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData As Long) As Long
Public Const HELP_FINDER = &HB&
Private Sub Form_Load() '主窗体载入
App.HelpFile = App.Path & "\help\*.HLP" '帮助文件
end sub
Private Sub MeuHelpFile_Click() '帮助主题-菜单
Dim Hlp As Long
Hlp = WinHelp(MainForm.hwnd, App.HelpFile, HELP_FINDER, CLng(0))
End Sub
方法3:
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
Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Function GetWinPath() As String
Dim S As String * 250, Length As Long
Length = GetWindowsDirectory(S, Len(S))
GetWinPath = Left(S, Length)
End Function
Public 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