How to Invoke Search in Windows Help from Visual Basic Program

Last reviewed: June 21, 1995
Article ID: Q86771
The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic for

  Windows, version 2.0
- Microsoft Visual Basic programming system for Windows, version 1.0 - Microsoft Windows versions 3.0 and 3.1

SUMMARY

You can invoke the Search feature of the Windows version 3.0 and 3.1 Help engine from a Visual Basic program. To do this, call the Windows API function WinHelp and pass the constant HELP_PARTIALKEY (&H105) as the wCommand parameter and any string that is a NON-valid topic as the dwData parameter.

MORE INFORMATION

Step-by-Step Example

1. Start Visual Basic or from the File menu, choose New Project (ALT, F, N)
   if Visual Basic is already running. Form1 is created by default.

  • In GLOBAL.BAS (or the .BAS file of your choice in Visual Basic version 2.0), add this code:

    Global Const HELP_PARTIALKEY = &H105

       ' Enter the following Declare statement entirely on one, single line.
       Declare Function WinHelp Lib "User"(ByVal hWnd As Integer,
          ByVal lpHelpFile As String, ByVal wCommand As Integer,
          ByVal dwData As Any) As Integer
    
    

  • In the Form1 Click event procedure, add this code:

       Sub Form_Click ()
          DummyVal$ = ""
          ' Enter the following function call entirely on one, single line:
          Temp% = WinHelp(Form1.hWnd, "c:\Windows\winhelp.hlp",
             HELP_PARTIALKEY, DummyVal$)
       End Sub
    
    

  • Press F5 to run this example. Click the form.


  • Additional reference words: 1.00 2.00
    KBCategory: kbprg kbcode
    KBSubcategory: APrgOther


    THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

    Last reviewed: June 21, 1995
    © 1998 Microsoft Corporation. All rights reserved. Terms of Use.