7

I am trying to get a CHM file to open to a specific topic using C#.

I have tried using

Help.ShowHelp(this, path, HelpNavigator.Topic, "TopicTitle");

but it doesn't find the page. I must not be keying in the topic title correctly. Is there a way that I can programatically retrieve all of the topics from a CHM file so that I can see what they are?

bluish
  • 26,356
  • 27
  • 122
  • 180
PICyourBrain
  • 9,976
  • 26
  • 91
  • 136

4 Answers4

7

No, the HtmlHelp API function is far too primitive to support enumerating topics. You could use the 7-zip file manager to look inside the .chm file. Right-click the file and choose "Open Inside". Or use the help authoring tool that was used.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
4

If you open a CHM file, and right click on a help page, you can choose the Properties command.
In the middle of the Properties page there is a property called: Address (URL).
The end of the URL contains the topic string used to open the help file to the correct page.

Here is an example: mk:@MSITStore:C:\Program%20Files\Sisulizer%202010\Sisulizer.chm::/OutputFiles.htm

If the URL is too long to see the topic at the end, you can select the address with your mouse and scroll to the end.

Here is a screen shot.

enter image description here

Zamboni
  • 7,897
  • 5
  • 43
  • 52
  • Wonderful, doing what you says gives a different anchor string than the one in the HTML file. It changes the help file's scroll position AND the highlighted content in the list on the left (using the 'obvious' anchor name only changes the former). Thanks! – Dan W Oct 16 '12 at 19:29
1

You may also use the following, where path is path to the chm file:

using System.Windows.Forms;

Help.ShowHelp(this, path, HelpNavigator.KeywordIndex, "Topic title");
Adam Szabo
  • 11,302
  • 18
  • 64
  • 100
0

I am not sure about how to programmatically retrieve topics from CHM. But I changed the one line code this way and it worked.

Help.ShowHelp(this, path , HelpNavigator.TopicId,"TopicTitle");
wattostudios
  • 8,666
  • 13
  • 43
  • 57
Amit
  • 1