Interfacing to MS Help 2 DExplore Viewer using its undocumented COM
Interface.
by Rob Chandler, MS Help MVP,
http://helpware.net
Last Update: 24-May-2003
Introduction & Download | Looking for Clues | Documentation
Others Say:
*** This API is Not Support by Microsoft ***
Dexplore is the document viewer that ships with VS and MSDN and is essentially MS's standard viewer for Help 2.x content. If you have ever looked at DExplore's limited set of command line parameters with disappointment then be disappointed no more. DExplore does have a rich (undocumented) COM interface. This document introduces you to that COM interface. And if this still does not satisfy then consider the two MVP H2 viewers that are available: Helpware viewer & HelpCenter viewer.
Most of the interface is obvious (if you are familiar with MS Help 2). Some corners of the interface are not so obvious and I invite anyone who wants to contribute to this document to please Contact me.
Demo source code is in Borland Delphi, however VB, C++, C# programmers who are familiar with COM should have no problems following and translating the code.
Download Demo: DExploreTest_exe.zip
Download Demo Delphi Source:
DExploreTest_src.zip
|
HKEY_CLASSES_ROOT\CLSID\{4A79114D-19E4-11d3-B86B-00C04F79F802} HKEY_CLASSES_ROOT\CLSID\{4A79114D-19E4-11d3-B86B-00C04F79F802}\TypeLib = {83285928-227C-11d3-B870-00C04F79F802} HKEY_CLASSES_ROOT\CLSID\{4A79114D-19E4-11d3-B86B-00C04F79F802}\LocalServer32 = c:\Program Files\Common Files\Microsoft Shared\Help\dexplore.exe HKEY_CLASSES_ROOT\CLSID\{4A79114D-19E4-11d3-B86B-00C04F79F802}\ProgID = DExplore.AppObj.7 HKEY_CLASSES_ROOT\CLSID\{4A79114D-19E4-11d3-B86B-00C04F79F802}\VersionIndependentProgID = DExplore.AppObj
HKEY_CLASSES_ROOT\TypeLib\{83285928-227C-11D3-B870-00C04F79F802} |
So vshelp.tlb is the Type Library file for DExplore. Note the COM
Program ID = DExplore.AppObj.
(note above is the VS 7.x DExplore GUID. VS 8.x has a different GUID)
| <SCRIPT language="jscript"> var viewer; var helpHost; function Link(url) { viewer = new ActiveXObject("DExplore.AppObj.7"); helpHost = viewer.Help; helpHost.SetCollection("ms-help://MS.NETFrameworkSDK", ".NET Framework SDK Documentation"); helpHost.DisplayTopicFromURL(url); helpHost.SyncContents(url); } </SCRIPT> <A href="javascript:Link('ms-help://MS.NETFrameworkSDK/cpguidenf/html/cpcongettingstartedwithnetframework.htm')">Getting Started with the .NET Framework </A> <A href="javascript:Link('ms-help://MS.NETFrameworkSDK/sdkstart/html/sdkstart.htm')">.NET Framework SDK documentation</A> |
This script simply loads the .NET SDK Collection into DExplore and displays and syncs a URL.
helpHost = viewer.Help; This line is not clear since viewer.help normally contains
the same thing as HelpHost anyway.
Notice that DExplore is not marked Safe For Scripting (see 2. above) so opening DExplore
via
IE will cause a warning message to appear before executing the command.
As stated there is no MS documentation so here's what we have found so far.
Special Note: Each call should be wrapped in a Try/Except block to trap errors (which occur if say a URL or collection parameter is not valid).
Getting the Help interface (Delphi example).
| var _VSHelpObj,
_Help: Variant; begin _VSHelpObj := CreateOleObject('DExplore.AppObj'); _Help := _VSHelpObj.Help; //note: what's the point here? Normally _helpHost == _VSHelpObj.Help anyway. |
After creating your main COM object (in this case "_Help"), the SetCollection() and DisplayTopicFromURL() methods are normally all you need to open a collection and display a URL while showing the DExplore window.
|
_Help.SetCollection(nsName: WideString, sFilter: WideString); |
|
| Property _Help.function Collection: WideString; |
|
| _HelpHost.DisplayTopicFromURL(sURL: WideString); |
|
| _Help.SyncContents(sURL: WideString); |
|
| _Help.GetNextTopic(sURL: WideString): WideString; |
|
| _Help.GetPrevTopic(sURL: WideString): WideString; |
|
| _Help.CanSyncContents(sURL: WideString); |
|
VS .NET tend to keep its help context mapping table in the "F" Index table of the help collection. The alternative is to keep your help context mappings in say an INI file that the main application can read and then calls DisplayTopicFromURL().
| _Help.DisplayTopicFromId(sFile: WideString; Id: LongWord); |
|
| _Help.DisplayTopicFromF1Keyword(sKeyword: WideString); |
|
| _Help.DisplayTopicFrom_OLD_Help(sFile: WideString; Id: LongWord); |
|
Visible keywords, displayed in the Index Navigation pane of DExplore, live in the "K" Index.
|
_Help.DisplayTopicFromKeyword(sKeyword: WideString); |
|
|
_Help.SyncIndex(sKeyword: WideString; iShow: Integer); |
|
| _Help.Contents; |
|
| _Help.Index; |
|
| _Help.Search; |
|
| _Help.IndexResults; |
|
| _Help.SearchResults; |
|
| _Help.Close; |
|
Note there is no method to applying a filterquery string. Applying a filter by its filtername works but these predefined filters can be edited by the user. Note: Our H2Viewer can apply filterquery strings.
|
_Help.FilterUI(); |
|
| Property _Help.Filter: WideString; |
|
| Property _Help.FilterQuery: WideString; |
|
| _Help.CanShowFilterUI(); |
|
These commands have not part of the Delphi Demo.
|
_Help.DisplayTopicFromURLEx(sURL:
WideString; pIVsHelpTopicShowEvents: IVsHelpTopicShowEvents); |
|
| Property _Help.HxSession: IDispatch; |
|
|
_Help.Help: IDispatch read Get_Help; |
_VSHelpObj := CreateOleObject('DExplore.AppObj'); //returns
interface address value xyz |
| _Help.GetObject(const bstrMoniker: WideString; const bstrOptions: WideString): IDispatch; |
|
| Property HelpOwner: IVsHelpOwner |
|
Topics in Bold show the methods or properties successfully exercised in the accompanying Delphi demo
and documentation above.
Topics prefixed with ? I have no idea about.
procedure Contents; safecall;
procedure Index; safecall;
procedure Search; safecall;
procedure IndexResults; safecall;
procedure SearchResults; safecall;
procedure DisplayTopicFromId(const bstrFile: WideString; Id: LongWord); safecall;
procedure DisplayTopicFromURL(const pszURL: WideString); safecall;
? procedure DisplayTopicFromURLEx(const pszURL: WideString; const
pIVsHelpTopicShowEvents: IVsHelpTopicShowEvents); safecall;
procedure DisplayTopicFromKeyword(const pszKeyword: WideString); safecall;
procedure DisplayTopicFromF1Keyword(const pszKeyword: WideString); safecall;
procedure DisplayTopicFrom_OLD_Help(const bstrFile: WideString; Id:
LongWord); safecall;
procedure SyncContents(const bstrURL: WideString); safecall;
?
procedure CanSyncContents(const bstrURL: WideString); safecall;
function GetNextTopic(const bstrURL: WideString): WideString; safecall;
function GetPrevTopic(const bstrURL: WideString): WideString; safecall;
procedure FilterUI; safecall;
?
procedure CanShowFilterUI; safecall;
procedure Close; safecall;
procedure SyncIndex(const bstrKeyword: WideString; fShow: Integer); safecall;
procedure SetCollection(const bstrCollection: WideString; const bstrFilter:
WideString); safecall;
function Get_Collection: WideString; safecall;
function Get_Filter: WideString; safecall;
procedure Set_Filter(const pbstrFilter: WideString); safecall;
function Get_FilterQuery: WideString; safecall;
?
function Get_HelpOwner: IVsHelpOwner; safecall;
?
procedure Set_HelpOwner(const ppObj: IVsHelpOwner); safecall;
function Get_HxSession: IDispatch; safecall;
function Get_Help_: IDispatch; safecall;
? function GetObject(const bstrMoniker: WideString; const bstrOptions: WideString):
IDispatch; safecall;
property Collection: WideString read Get_Collection;
property Filter: WideString read Get_Filter write Set_Filter;
property FilterQuery: WideString read Get_FilterQuery;
?
property HelpOwner: IVsHelpOwner read Get_HelpOwner write Set_HelpOwner;
property HxSession: IDispatch read Get_HxSession;
property Help_: IDispatch read Get_Help_;
Subject: VS .NET 2003 - Using VsHelp.tlb with C#.
From: by Michael Waltuch from
ESRI
Date: 24-May-2003
VS .NET
2003 - Using VsHelp.tlb with C#.
View code for the form (Form1.cs). private void DispHelp(String url)
{
//Help interface must be fully qualified because it's ambiguous otherwise
VsHelp.Help h = new VsHelp.DExploreAppObjClass();
h.SetCollection("ms-help://ms.vscc.2003","");
h.DisplayTopicFromURL(url);
h.SyncContents(url);
}
Add a button to the form. Double-click it
to view its Click event. Call the method you created earlier, for example: |
Subject: Call MSHelp2 topic
from C# via DTE
From: Charles Lloyd <...@epicor.com>
Date: 5-March-2004
Rob: As Charles suggests you can also access VS .NET IDE via the DTE Object. For more info see VS: Referencing the DTE Object
| Just in case anybody is interested in comparing examples of
the Dexplore COM interface and referencing the DTE to do the same thing
(call a Help2 topic via an "F" keyword from a custom C# form inside of
Visual Studio). Dexplore way (see Helpware site for details): private void displaySDKF1(string F1Keyword)
{
VsHelp.Help h = new VsHelp.DExploreAppObjClass();
h.SetCollection("ms-help://MS.VSCC.2003","");
h.DisplayTopicFromF1Keyword(F1Keyword);
}
Cons: not officially supported. Error handling tougher. Pro: probably
will private void displayViaDTE(string F1Keyword)
{
EnvDTE.DTE dte;
dte =
(EnvDTE.DTE)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualSt
udio.DTE.7.1");
dte.ExecuteCommand("Help.F1Help",F1Keyword);
}
Cons: must have an instance of VS running. |
MVP Rob Cavicchio posts that VS 2005 now has its own Help 2 API which MS have published in MSDN.
http://msdn2.microsoft.com/en-us/library/microsoft.visualstudio.vshelp80.help2(vs.80).aspx