Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

WinHelp (user32)
 
.
Summary

C# Signature:

[DllImport("user32.dll")]
static extern bool WinHelp(IntPtr hWndMain, string lpszHelp, uint uCommand,
   uint dwData);

VB.NET Signature:

<DllImport("user32.dll", SetLastError:=True, Charset:=Charset.Ansi)> _
Public Function bool WinHelp(hWndMain As IntPtr, _
    <MarshalAs(UnmanagedType.LPStr)>lpszHelp As String, _
    uCommand As UInteger, _
    dwData As UInteger) As <MarshalAs(UnmanagedType.Bool)> Boolean
End function

User-Defined Types:

[Enums.WinHelpCommands]

Notes:

Here are the constants defined in Winver.h:

    // Commands to pass to WinHelp()
    const uint HELP_CONTEXT      = 0x0001;  /* Display topic in ulTopic */
    const uint HELP_QUIT         = 0x0002;  /* Terminate help */
    const uint HELP_INDEX    = 0x0003;  /* Display index */
    const uint HELP_CONTENTS     = 0x0003;
    const uint HELP_HELPONHELP   = 0x0004;  /* Display help on using help */
    const uint HELP_SETINDEX     = 0x0005;  /* Set current Index for multi index help */
    const uint HELP_SETCONTENTS  = 0x0005;
    const uint HELP_CONTEXTPOPUP = 0x0008;
    const uint HELP_FORCEFILE    = 0x0009;
    const uint HELP_KEY      = 0x0101; /* Display topic for keyword in offabData */
    const uint HELP_COMMAND      = 0x0102;
    const uint HELP_PARTIALKEY   = 0x0105;
    const uint HELP_MULTIKEY     = 0x0201;
    const uint HELP_SETWINPOS    = 0x0203;
    const uint HELP_CONTEXTMENU  = 0x000a;
    const uint HELP_FINDER       = 0x000b;
    const uint HELP_WM_HELP      = 0x000c;
    const uint HELP_SETPOPUP_POS = 0x000d;

    const uint HELP_TCARD          = 0x8000;
    const uint HELP_TCARD_DATA     = 0x0010;
    const uint HELP_TCARD_OTHER_CALLER = 0x0011;

    const uint IDH_NO_HELP         = 28440;
    const uint IDH_MISSING_CONTEXT     = 28441; // Control doesn't have matching help context
    const uint IDH_GENERIC_HELP_BUTTON = 28442; // Property sheet help button
    const uint IDH_OK          = 28443;
    const uint IDH_CANCEL          = 28444;
    const uint IDH_HELP        = 28445;

Tips & Tricks:

Please add some!

Sample Code:

    [DllImport("user32.dll")]
    static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

    [DllImport("user32.dll")]
    static extern bool WinHelp(IntPtr hWndMain, string lpszHelp, uint uCommand, uint dwData);

    const uint YOUR_CONTEXT_SENSITIVE_HELP_ID = 32862;
    string lpszClass = "WindowsForms10.Window.8.app3";
    string lpszWindow = "Your Window Title";

    IntPtr ParentHWnd = new IntPtr(0);
    ParentHWnd = FindWindow(lpszClass, lpszWindow);

    if (!ParentHWnd.Equals(IntPtr.Zero))
    {
        bool ret = WinHelp(ParentHWnd, "Your help file.hlp", HELP_CONTEXT, YOUR_CONTEXT_SENSITIVE_HELP_ID);
    }

Alternative Managed API:

Do you know one? Please contribute it!

Documentation
WinHelp on MSDN

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions