Calling Help Viewer 1.0 from Visual Studio add-in code
The Visual Studio interface for launching Help using an F keyword (context sensitive help keyword) has not changed since 2002, but I had the hardest time finding some sample code for it recently *anywhere*. (See this page for some additional detail on what has changed in the IVsHelp interface in general for VS 2010.)
Below are the basic details for referencing the interops necessary for calling DisplayTopicFromF1Keyword (whether in VS 2008 with the old help system or in VS 2010 with Help Viewer 1.0). I'm a C# developer, so my example is assuming C#.
- Add the following COM references to your project:
- VsHelp
- VsHelp80
- Add the following using statement to your unit:
using Microsoft.VisualStudio.VSHelp;
Finally, you need to use GetService() to obtain an instance of the object to call the method:
Help objHelp = (VsHelp.Help)GetService(typeof(SVsHelp));
objHelp.DisplayTopicFromF1Keyword("some.F1.Keyword");
The value "some.F1.Keyword", can be any string that matches an F keyword defined your content. In Help 2.x, F keywords are defined in the <xml> data islands in your topics (or possibly in a compile time .hxk file):
<MSHelp:Keyword Index="F" Term="Microsoft.Build.Tasks.Windows.FileClassifier" />
In MSHC files (Help Viewer 1.0), these are defined as standard metadata on your topics, using our custom attribute:
<meta name="Microsoft.Help.F1" content="Microsoft.Build.Tasks.Windows.FileClassifier"/>
The F keywords are then all combined together into an index for these context sensitive help lookups.