Show Sitemap ..Help2HTMLHelpWinHelp

HTMLHelp API - VBA, VB6 und VB2003

Download

FAQ

Links

HTMLHelp API - Deklaration

Die HtmlHelp() API Funktion wird wie folgt deklariert:

Declare Function HtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" _
(ByVal hwndCaller As Long, ByVal pszFile As String, _
ByVal uCommand As Long, ByVal dwData As Long) As Long

hwndCaller
Der hwndCaller Element ist definiert als ein Handle des Anwendungsfensters oder Null. Wenn ein Fensterhandle angegeben wird, wird das HTML Hilfefenster gezwungen oberhalb des aufrufenden Fensters zu sein. Wenn eine 0 (null) angegeben wird, tritt diese Bedingung nicht auf.

Wenn ein Handle erfolgt besitzt das entsprechende Fenster das HTMLHelp Fenster und empfängt alle mögliche Meldungen, die durch HTMLHelp an das Besitzerfenster zurück gesendet werden. Indem dieses auf Null (0& im VB Sprachgebrauch) gesetzt wird setzt man effektiv fest, dass der Desktop der Inhaber ist und so wird ermöglicht das Fenster hinter das Anwendungsfenster fallen zu lassen.

pszFile
Die anzuzeigende Datei; wahlweise wird hier angegeben, welcher Fenstertyp gewählt wird, und zwar abgegrenzt durch das rechtsgercihtete Winkelzeichen (Dateiname>Fenstertyp). Wenn Sie den Fenstertyp weglassen, verwendet die Funktion HtmlHelp den in der HTML Hilfeprojektdatei angegebenen Standardfenstertyp. Für uCommand Werte, die keine Quellendatei erfordern, kann in VBA pszFile Null oder 0 (null) sein. Eine kompilierte HTML Hilfedatei wird aber normalerweise angegeben.

uCommand
Die auszuführende Aktion; siehe den Rest dieses Abschnitts für Beispiele, wie man ein Hilfethema entweder durch den Befehl HH_HELP_CONTEXT oder HH_DISPLAY_TOPIC anzeigen kann.
HH_DISPLAY_TOPIC
Zeigt ein Hilfethema durch übermitteln der URL von der HTML-Datei an, die das Thema als das dwData Argument enthält.
HH_HELP_CONTEXT
Zeigt ein Hilfethema durch übermitteln der passenden Kontext-ID für das Thema als das dwData Argument an.

dwData
Gibt weitere Daten je nach dem Wert von uCommand an. Beachten Sie, dass in der Deklaration dieses Argument als Any definiert ist, weil dieses Argument mehrere verschiedene Datentypen akzeptiert. Sie müssen darauf achten, den richtigen Datentyp zu übermitteln oder einen ungültigen Seitenfehler zu riskieren (bekann??S???t als allgemeiner Schutzfehler [General Protection Fault]).

Rückgabewerte

Abhängig von dem spezifizierten uCommand und dem Resultat gibt HTMLHelp einen oder beide vom folgenden zurück:

HTMLHelp API - HH_CLOSE ALL Hinweis

If you call the HH API directly from your application, and not via a second helper program like HH.EXE or KEYHH.EXE, then you MUST close any open help windows before shutting down the application or you will probably crash Windows.

The call to close all windows is simply. Because of a bug in the HH API make sure you call this in your main form's Query_Unload event not OnClose.

Weitere Information in unserer Wissenbasis: HH_CLOSE_ALL Bug and HH_INITIALIZE

Private Sub Query_Unload(Cancel As Integer)
   Call HtmlHelp(Me.hWnd, "", HH_CLOSE_ALL, 0)
End Sub. 

EXCEL VBA Workaround:

Siehe auch: Download EXCEL Beispiel

Trying to get around Excel crashing with a GPF General Protection Fault (Microsoft Windows program crash/error) when I tried to close the help file using HTMLHelp 0&, "", HH_CLOSE_ALL, 0&. The Microsoft knowledge base and other solutions on the Net suggested changes to the registry, which is not practical as would have to go to each user's PC to implement that. So had to use the tried and tested method of problem solving: Used random changes to see what works. The method that works, is to not leave the pszFile parm blank as the API says in the close_all call, but to give the CHM file name there.

So this seems to work if only one help window is open:

Call HtmlHelp(0, ThisWorkbook.Path & "\CHM-example.chm", HH_CLOSE_ALL, 0)

Search From Application

HH Workshop API documents how to move to the search tab and initiate a search. Unfortunately the initiating a search part has always been broken in HH. The only way around this would be to find the HH window and search pane controls. Then control those controls from your application using via low level Windows API calls.

Dmitry Karpezo, <dkarpezo AT lycosmail.com> posted a small code example for C++ on MSHelp2 Yahoo group

The Visual Basic form this site includes a Visual Basic 6 translation and GUI example. See modul below:

'******************************************************************************
'----- Modul HH API for Visual Basic 6 - (c) Ulrich Kulle
'----- 2006-08-28 Version 1.0 first release for performing a search from application
'******************************************************************************
'----- Thanks to Dimitry Karpezo for the C++ version of this code
'------------------------------------------------------------------------------

Private Declare Function HtmlHelpSearch Lib "hhctrl.ocx" Alias "HtmlHelpA" _
                (ByVal hwndCaller As Long, ByVal pszFile As String, _
                ByVal uCommand As Long, dwData As HH_FTS_QUERY) As Long
         
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
                (ByVal hwnd As Long, ByVal wMsg As Long, _
                ByVal wParam As Long, ByVal lParam As Any) As Long
                
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
                (ByVal hWndParent As Long, ByVal hWndChildAfter As Long, _
                ByVal lpClassName As String, ByVal lpWindowName As String) As Long
                
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" _
                (ByVal hwnd As Long, ByVal lpClassName As String, _
                ByVal nMaxCount As Long) As Long
        
Public Declare Function GetDlgItem Lib "user32" _
                (ByVal hDlg As Long, ByVal nIDDlgItem As Long) As Long
                
' API const
'------------------------------------------------------------------------------
Public Const WM_COMMAND As Long = &H111     ' WM_COMMAND = 0x0111
Public Const WM_SETTEXT As Long = &HC       ' WM_SETTEXT = 0x000C

                
' HH API const
'------------------------------------------------------------------------------
Public Const HH_DISPLAY_TOPIC = &H0         ' select last opened tab, [display a specified topic]
Public Const HH_DISPLAY_TOC = &H1           ' select contents tab, [display a specified topic]
Public Const HH_DISPLAY_INDEX = &H2         ' select index tab and searches for a keyword
Public Const HH_DISPLAY_SEARCH = &H3        ' select search tab (perform a search is fixed here)
      
Private Const HH_SET_WIN_TYPE = &H4
Private Const HH_GET_WIN_TYPE = &H5
Private Const HH_GET_WIN_HANDLE = &H6
Private Const HH_DISPLAY_TEXT_POPUP = &HE   ' Display string resource ID or
  
Private Const HH_HELP_CONTEXT = &HF          ' display mapped numeric value in dwData
     
Private Const HH_TP_HELP_CONTEXTMENU = &H10 ' Text pop-up help, similar to WinHelp
Private Const HH_TP_HELP_WM_HELP = &H11     ' text pop-up help, similar to WinHelp

' HH_DISPLAY_SEARCH Command Related Structures and Constants
'-----------------------------------------------------------
Public Const HH_FTS_DEFAULT_PROXIMITY = -1
Public Const HH_MAX_TABS = 19               ' maximum number of tabs

Public Type HH_FTS_QUERY                    ' UDT for accessing the Search tab
  cbStruct          As Long                 ' Sizeof structure in bytes.
  fUniCodeStrings   As Long                 ' TRUE if all strings are unicode.
  pszSearchQuery    As String               ' String containing the search query.
  iProximity        As Long                 ' Word proximity.
  fStemmedSearch    As Long                 ' TRUE for StemmedSearch only.
  fTitleOnly        As Long                 ' TRUE for Title search only.
  fExecute          As Long                 ' TRUE to initiate the search.
  pszWindow         As String               ' Window to display in
End Type

Public Sub PerformSearch(ByVal intHelpFile As Integer, ByVal sSearch As String, _
Optional ByVal bShowFirstResult As Boolean)
'------------------------------------------------------------------------------
' show search tab and perform search
' ** BUG: ** HTML Help: HH_DISPLAY_SEARCH API Command Does Not Perform a Search
' http://support.microsoft.com/kb/241381/en-us
' fixed by translation from C++ code from Dimitry Karpezo
'------------------------------------------------------------------------------
Dim bDisplayFirstTopic As Boolean
Dim searchIt As HH_FTS_QUERY
Dim RetVal As Long
Dim hwndhelp As Long            '---
Dim hPaneWnd As Long            '---
Dim hPaneLast As Long           '---
Dim hTabWnd As Long             '---
Dim hDlgWnd As Long             '---
Dim hCtlWnd As Long             '---

  '--- check for search term --------------------------------------------------
  If Len(sSearch) = 0 Then
    MsgBox "Please input a Search Term!"
    Exit Sub
  End If

  '--- First, invoke HtmlHelp with HH_DISPLAY_SEARCH.
  '--- It doesn't execute search, but it's need for showing 'search' tab.
  '----------------------------------------------------------------------------
  With searchIt
    .cbStruct = Len(searchIt)               ' Size of structute in bytes
    .fUniCodeStrings = 0&                   ' TRUE if all strings are unicode
    .pszSearchQuery = sSearch               ' String containing the search query
    .iProximity = HH_FTS_DEFAULT_PROXIMITY  ' word proximity
    .fStemmedSearch = 0&                    ' TRUE for StemmedSearch only
    .fTitleOnly = 1&                      ' TRUE for Title Search only
    .fExecute = 0&                         ' TRUE to initiate the search
    .pszWindow = ""                         ' Window to display in
  End With
  hwndhelp = HtmlHelpSearch(0&, HFile(intHelpFile), HH_DISPLAY_SEARCH, searchIt)
  '--- Find query combobox at help viewers search tab and set query text.
  '----------------------------------------------------------------------------
  hPaneWnd = FindWindowEx(hwndhelp, ByVal CLng(0), "HH Child", vbNullString)
  For i = 1 To HH_MAX_TABS        '--- tab's limited to 19
    '--- last HH Child --------------------------------------------------------
    hPaneLast = FindWindowEx(hwndhelp, hPaneWnd, "HH Child", vbNullString)
    If hPaneLast = 0 Then Exit For
    hPaneWnd = hPaneLast
  Next i
  '--- skip Tab Control -------------------------------------------------------
  hCtlWnd = FindWindowEx(hPaneWnd, ByVal CLng(0), "Button", vbNullString)
  
  If hCtlWnd <> 0 Then
    '----------------------------------------------------------------------------
    ' There are two types of interfaces:
    '
    ' 1.
    ' Window hierarchy:
    ' + Main window
    '   + HH Child
    '     + Browser ...
    '   + HH Child       <- second "HH Child" window
    '         - Edit     <- we have to fill this edit
    '         - Buttons  <- and press this buttons
    '         ...
    '----------------------------------------------------------------------------
    '--- skip Tab Control -----
    hCtlWnd = FindWindowEx(hPaneWnd, ByVal CLng(0), "Edit", vbNullString)
    ' Set window text and fill it by our query
    '--------------------------------------------------------------------------
    SendMessage hCtlWnd, WM_SETTEXT, ByVal CLng(0), sSearch
    '--- // 0x3ee (?) 0xbc7 -- 'List Topics' button, it runs search
    SendMessage hwndhelp, WM_COMMAND, &HBC7, ByVal CLng(0)
    
    '--- // 0x3f1 (?) 0xbbe -- 'Display' button, it shows first item
    If bShowFirstResult Then
      SendMessage hwndhelp, WM_COMMAND, &HBBE, ByVal CLng(0)
    End If
  
  Else
    '----------------------------------------------------------------------------
    ' 2.
    ' Window hierarchy:
    ' + Main window
    '   + HH Child
    '     + Browser ...
    '   + HH Child       <- second "HH Child" window
    '     + Tab Control
    '       + Dialog
    '         - Combobox <- we have to fill this combo
    '         - Buttons  <- and press this buttons
    '         ...
    '----------------------------------------------------------------------------
    '--- skip Tab Control
    hTabWnd = FindWindowEx(hPaneWnd, ByVal CLng(0), "SysTabControl32", vbNullString)
    '--- skip dialog
    hDlgWnd = FindWindowEx(hTabWnd, ByVal CLng(0), vbNullString, vbNullString)
    '--- create a string-buffer
    Dim szClass As String * 255
    RetVal = GetClassName(hDlgWnd, szClass, 255)
    
    ' e.g. a standard Windows Message Box has the class name "#32770".
    '--------------------------------------------------------------------------
    If Not Left(szClass, 1) = "#" Then                  '--- Is it dialog?
      '--- skip dialog      
      hDlgWnd = FindWindowEx(hTabWnd, hDlgWnd, vbNullString, vbNullString)     
    End If
    '--- well, it's combobox
    hCtlWnd = FindWindowEx(hDlgWnd, ByVal CLng(0), "ComboBox", vbNullString)    

    ' Set window text and fill it by our query
    '--------------------------------------------------------------------------
    SendMessage hCtlWnd, WM_SETTEXT, ByVal CLng(0), sSearch

    ' Run search
    ' -------------------------------------------------------------------------
    '--- 0x3ee -- 'List Topics' button, it runs search
    SendMessage hwndhelp, WM_COMMAND, &H3EE, ByVal CLng(0)

    ' Show first query result [optional]
    ' -------------------------------------------------------------------------
    '--- 0x3f1 -- 'Display' button, it shows first item
    If bShowFirstResult Then
      SendMessage hwndhelp, WM_COMMAND, &H3F1, ByVal CLng(0)
    End If
  End If
End Sub


HTMLHelp und Visual Basic for Applications

Wie kann man HTMLHelp von einem VBA Makro aufrufen?

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
    
Const HH_DISPLAY_TOPIC = &H0
Const HH_SET_WIN_TYPE = &H4
Const HH_GET_WIN_TYPE = &H5
Const HH_GET_WIN_HANDLE = &H6
Const HH_DISPLAY_TEXT_POPUP = &HE   ' Display string resource ID or text in a pop-up window.
Const HH_HELP_CONTEXT = &HF         ' Display mapped numeric value in dwData.
Const HH_TP_HELP_CONTEXTMENU = &H10 ' Text pop-up help, similar to WinHelp's HELP_CONTEXTMENU.
Const HH_TP_HELP_WM_HELP = &H11     ' text pop-up help, similar to WinHelp's HELP_WM_HELP.


Sub OpenHelp(ByVal ContextId As Long)
Dim hwndHH as Long
    'The return value is the window handle of the created help window.
    hwndHH = HtmlHelp(0, ThisWorkbook.Path & "\" & AppId & ".chm", HH_HELP_CONTEXT, ContextId)
End Sub

übergeben wird die Context_ID.

Um das Standardthema der Datei HTMLHelp aufzurufen versuchen Sie bitte:

hwndHH = HtmlHelp(0, ThisWorkbook.Path & "\" & "Helpfile" & ".chm", HH_DISPLAY_TOPIC, 0)

HTMLHelp und Visual Basic 6

Verwendung eines Moduls für Visual Basic 6 Projekte

Beim Steuerelement, für welches die Hilfe aufgerufen werden soll, ist dann unter Visual Basic bei der Eigenschaft HelpContextID z.B. 1030 einzutragen. Die genaue Vorgehensweise kann im Beispielprojekt erkannt werden.

Beispiel:

'******************************************************************************
'----- Modul - definition for HTMLHelp - (c) Ulrich Kulle
'----- 2002-08-26 Version 1.0 first release
'----- 2005-07-17 Version 1.1 updated for Pop-Up help
'******************************************************************************
'----- Portions of this code courtesy of David Liske.
'----- Thanks to David Liske, Don Lammers, Matthew Brown and Thomas Schulz
'------------------------------------------------------------------------------
Type HH_IDPAIR
  dwControlId As Long
  dwTopicId As Long
End Type

'This array should contain the number of controls that have
'context-sensitive help, plus one more for a zero-terminating
'pair.

Public ids(2) As HH_IDPAIR

Declare Function GetDlgCtrlID Lib "user32" _
  (ByVal hwnd As Long) As Long

Public Declare Function HtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" _
               (ByVal hwndCaller As Long, ByVal pszFile As String, _
                ByVal uCommand As Long, ByVal dwData As Long) As Long
                
Declare Function HTMLHelpTopic Lib "hhctrl.ocx" Alias "HtmlHelpA" _
               (ByVal hwndCaller As Long, ByVal pszFile As String, _
                ByVal uCommand As Long, ByVal dwData As String) As Long
         
Private Declare Function HtmlHelpSearch Lib "hhctrl.ocx" Alias "HtmlHelpA" _
               (ByVal hwndCaller As Long, ByVal pszFile As String, _
                ByVal uCommand As Long, dwData As HH_FTS_QUERY) As Long
         

Public Const HH_DISPLAY_TOPIC = &H0         ' select last opened tab, [display a specified topic]
Public Const HH_DISPLAY_TOC = &H1           ' select contents tab, [display a specified topic]
Public Const HH_DISPLAY_INDEX = &H2         ' select index tab and searches for a keyword
Public Const HH_DISPLAY_SEARCH = &H3        ' select search tab and perform a search
      
Private Const HH_SET_WIN_TYPE = &H4
Private Const HH_GET_WIN_TYPE = &H5
Private Const HH_GET_WIN_HANDLE = &H6
Private Const HH_DISPLAY_TEXT_POPUP = &HE   ' Display string resource ID or
  
Public Const HH_HELP_CONTEXT = &HF          ' display mapped numeric value in dwData
     
Private Const HH_TP_HELP_CONTEXTMENU = &H10 ' Text pop-up help, similar to WinHelp's HELP_CONTEXTMENU.
Private Const HH_TP_HELP_WM_HELP = &H11     ' text pop-up help, similar to WinHelp's HELP_WM_HELP.


Public Type HH_FTS_QUERY                ' UDT for accessing the Search tab
  cbStruct          As Long             ' Sizeof structure in bytes.
  fUniCodeStrings   As Long             ' TRUE if all strings are unicode.
  pszSearchQuery    As String           ' String containing the search query.
  iProximity        As Long             ' Word proximity.
  fStemmedSearch    As Long             ' TRUE for StemmedSearch only.
  fTitleOnly        As Long             ' TRUE for Title search only.
  fExecute          As Long             ' TRUE to initiate the search.
  pszWindow         As String           ' Window to display in
End Type

Public Function HFile(ByVal i_HFile As Integer) As String
'----- Set the string variable to include the application path of helpfile
  Select Case i_HFile
  Case 1
    HFile = App.Path & "\help\CHM-example.chm"
  Case 2
'----- Place other Help file paths in successive case statements
    HFile = App.Path & "\help\CHM-other-language.chm"
  End Select
End Function

Public Sub ShowContents(ByVal intHelpFile As Integer)
   HtmlHelp hwnd, HFile(intHelpFile), HH_DISPLAY_TOC, 0
End Sub

Public Sub ShowIndex(ByVal intHelpFile As Integer)
    HtmlHelp hwnd, HFile(intHelpFile), HH_DISPLAY_INDEX, 0
End Sub

Public Sub ShowTopic(ByVal intHelpFile As Integer, strTopic As String)
    HTMLHelpTopic hwnd, HFile(intHelpFile), HH_DISPLAY_TOPIC, strTopic
End Sub

Public Sub ShowTopicID(ByVal intHelpFile As Integer, IdTopic As Long)
  HtmlHelp hwnd, HFile(intHelpFile), HH_HELP_CONTEXT, IdTopic
End Sub
'------------------------------------------------------------------------------
'----- display the search tab
'----- bug: start searching with a string dosn't work
'------------------------------------------------------------------------------
Public Sub ShowSearch(ByVal intHelpFile As Integer)
Dim searchIt As HH_FTS_QUERY
  With searchIt
    .cbStruct = Len(searchIt)
    .fUniCodeStrings = 1&
    .pszSearchQuery = "foobar"
    .iProximity = 0&
    .fStemmedSearch = 0&
    .fTitleOnly = 1&
    .fExecute = 1&
    .pszWindow = ""
  End With
  Call HtmlHelpSearch(0&, HFile(intHelpFile), HH_DISPLAY_SEARCH, searchIt)
End Sub

HTMLHelp und Visual Basic 2003 (.net)

Hilfe zu Ihrer Anwendung zu liefern, sollte eines der Dinge sein, die Sie nicht auslassen sollten. Verwenden Sie die entsprechende Art der Hilfe, die auf den Bedarf Ihrer Anwendung zugeschnitten ist. Es ist manchmal besser, HTMLHelp Dateien (CHM) zu verwenden, aber es wird manchmal ausreichend sein, nur Pop-Up Hilfe oder ToolTips zu haben.

Wenn Sie schon Erfahrung mit VB6 haben, ist das Erste was Sie bei .NET Anwendungen bemerken können, dass diese den Aufruf der Hilfe über numerische Kontext-ID's nicht mehr unterstützen. Aber schauen Sie, was sich geändert hat wenn Sie den guten alten HTMLHelp API Aufruf verwenden ..

Hinweis:

Bei VB.net besteht ein grundlegendes Problem in der Deklaration des API Aufrufs. Sie müssen die LONG Deklaration in der API für .NET in IntPtr oder Int32 umwandeln, da Integer in .NET 32 Bit sind, während sie in VB6 16 Bit sind.

  Public Declare Function HTMLHelp_BaseCall Lib "hhctrl.ocx" Alias "HtmlHelpA" _
  (ByVal hWnd As IntPtr, ByVal lpHelpFile As String, _
  ByVal uCommand As Int32, ByVal dwData As Int32) As Int32

Verwendung eines Moduls für VB.net Projekte

Beispiel:

Module modHelp
  '------------------------------------------------------------------------
  '--- (c) Ulrich Kulle, 2004-09-03
  '--- The HTMLHelp function starts HTML Help and passes additional data
  '--- If the function succeeds, the return value is nonzero.
  '--- If the function fails, the return value is zero.

  Public Const HH_DISPLAY_TOPIC As Short = &H0    ' select last opened tab, [display a specified topic]
  Public Const HH_DISPLAY_TOC As Short = &H1      ' select contents tab, [display a specified topic]
  Public Const HH_DISPLAY_INDEX As Short = &H2    ' select index tab and searches for a keyword
  Public Const HH_DISPLAY_SEARCH As Short = &H3   ' select search tab and perform a search

  Public Const HH_HELP_CONTEXT As Short = &HF     ' display mapped numeric value in dwData

  '--- The parameters of the API call MUST be an Integer type
  '--- old VB6 definition of the parameters was 'As Long'
  '*** hWnd is the handle of the window requesting help
  '*** lpHelpFile is a string containing path, name of the helpfile
  '               [optional]: file of the specific topic
  '               [optional]: name of a secondary window
  '*** uCommand specifies the type of help requested
  '               see some Help Command Constants above
  '*** dwData specifies additional data. The value used despends on the value of uCommand
  '               VB6 declaration is 'As Any' or 'As Long' !!!

  '  ********** Changes  **********
  ' (VB.net):  Integer => IntPtr
  ' (VB.net):  Long => Int32
  ' (VB.net):  Long => Int32

  Public Declare Function HTMLHelp_BaseCall Lib "hhctrl.ocx" Alias "HtmlHelpA" _
  (ByVal hWnd As IntPtr, ByVal lpHelpFile As String, _
  ByVal uCommand As Int32, ByVal dwData As Int32) As Int32
 

Aufruf des Inhaltsverzeichnis (Table of Contents)

  Public Sub ShowContents(ByVal intHelpFile As Integer)
    '--- Call to show Table of Contents ---
    Dim RetVal As Int32
    RetVal = HTMLHelp_BaseCall(IntPtr.Zero, HFile(intHelpFile), HH_DISPLAY_TOC, 0)
  End Sub

Aufruf des Index

  Public Sub ShowIndex(ByVal intHelpFile As Integer)
    '--- Call to show Index --- 
    Dim RetVal As Int32
    RetVal = HTMLHelp_BaseCall(IntPtr.Zero, HFile(intHelpFile), HH_DISPLAY_INDEX, 0)
  End Sub

Aufruf eines Themas

  Public Sub ShowTopic(ByVal intHelpFile As Integer, ByVal strTopic As String)
    '--- Call to show topic ---
    Dim RetVal As Int32
    RetVal = HTMLHelp_BaseCall(IntPtr.Zero, HFile(intHelpFile) & "::/" & strTopic, HH_DISPLAY_TOC, 0)
  End Sub

Aufruf eines Themas über die ContextID

  Public Sub ShowTopicID(ByVal intHelpFile As Integer, ByVal IdTopic As Int32)
    '--- Call to show a topic by ContextID --- 
    Dim RetVal As Int32
    RetVal = HTMLHelp_BaseCall(IntPtr.Zero, HFile(intHelpFile), HH_HELP_CONTEXT, IdTopic)
  End Sub

To select a specific help file

  Public Function HFile(ByVal i_HFile As Integer) As String
    Dim sHelpFile As String
    Dim sStartupPath As String
    '--- Initialize context-sensitive help ---
    sStartupPath = Application.StartupPath.ToString

    Select Case i_HFile
      Case 1
        sHelpFile = Replace(sStartupPath, "\bin", "\hlp") & "\VBnetCHM.chm"
        Return sHelpFile
      Case 2
        '--- Place other help file paths in successive case statements
        sHelpFile = Replace(sStartupPath, "\bin", "\hlp") & "\Help_Coding-Example_VB6.chm"
        Return sHelpFile
    End Select
  End Function
Top ...