HOWTO: Call Win32 WinHelp API from Visual Basic

ID: Q202563


The information in this article applies to:
  • Microsoft Visual Basic Standard, Professional, and Enterprise Editions, 32-bit only, for Windows, version 4.0
  • Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, versions 5.0, 6.0


SUMMARY

This article demonstrates how to programmatically invoke the Windows 32-bit Help engine using the WinHelp API from a Visual Basic program.


MORE INFORMATION

The steps below provide sample code to programmatically call the 32-bit WinHelp API from a 32-bit Visual Basic application:

Step-by-Step Example

  1. Create a new Standard EXE project in Visual Basic. Form1 is created by default.


  2. Add a CommandButton (Command1) to Form1.


  3. Paste the following code into Form1's module:


  4. 
       Option Explicit
       
       Private 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
    
       Private Const HELP_CONTENTS = 3
       Private Const HELP_FINDER = 11
    
       Private Sub Command1_Click()
          Dim lResult As Long
          Dim sHelpFile As String
          Dim lCommand as Long, lOption as Long
          sHelpFile = "winfile.hlp"
          lCommand = HELP_CONTENTS
          lOption = 0
          lResult = WinHelp(Me.hwnd, sHelpFile, lCommand, lOption)
       End Sub 
  5. Run the project and click on the CommandButton.


  6. NOTE: The Help Constants topic of the Visual Basic Help file has additional values for the third parameter (command parameter). HELP_CONTENTS is still kept in WinHelp for backward compatibility with 16-bit Help files. The HELP_FINDER command is preferred for 32-bit Help files.


REFERENCES

Visual Basic API Text Viewer, Online Help and Books Online.

For additional information about invoking WinHelp, please click the article number below to view the article in the Microsoft Knowledge Base:

Q86771 HOWTO: Invoke Search in Windows Help from Visual Basic Program

Keywords : kbAPI kbWinHelp kbSDKWin32 kbVBp kbVBp400 kbVBp500 kbVBp600 kbGrpVB kbDSupport
Version : WINDOWS:4.0,5.0,6.0
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: October 8, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.