Microsoft KB Archive/202563

= How To Call Win32 WinHelp API from Visual Basic =

Article ID: 202563

Article Last Modified on 7/15/2004

-

APPLIES TO


 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition
 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q202563



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
 Create a new Standard EXE project in Visual Basic. Form1 is created by default. Add a CommandButton (Command1) to Form1.  Paste the following code into Form1's module: 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  Run the project and click on the CommandButton. 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.

