Question

I´m trying to call a chm file in my IronPython code that has a reference to a specific chapter.

Calling the chm file works fine Example:

  import clr
  clr.AddReference("System")
  from System.Diagnostics import Process
  Process.Start('''C:\planta\client\Help\Planta.chm''')

Calling the chm file won´t work ... can anybody help me?!?

  Process.Start('''C:\planta\client\Help\Planta.chm::/D-KA-0044095.html''')

Thank you!

Was it helpful?

Solution

There are different ways to accomplish what you are trying.

Sticking with the direction you started off you can determine the URL of the chapter and just try to launch it using Process.Start. This might open the correct help topic using a browser or similar viewer.

import clr
clr.AddReference("System")
from System.Diagnostics import Process
Process.Start(r"mk:@MSITStore:C:\planta\client\Help\Planta.chm::/D-KA-0044095.html")

If you want to use Microsoft's help viewer you can launch it in a similar way.

import clr
clr.AddReference("System")
from System.Diagnostics import Process
Process.Start("hh.exe", r"mk:@MSITStore:C:\planta\client\Help\Planta.chm::/D-KA-0044095.html")

A less error-prone way would be using Help.ShowHelp which handles your exact use case. The only possible downsides would be having to load WinForms and the fact that the help viewer attaches to your application/UI. So if you would like to start the viewer, terminate the IronPython process and keep the help viewer running you would have to take a closer look.

import clr
clr.AddReference('System.Windows.Forms')
from System.Windows.Forms import Help, HelpNavigator

helpFile = r"C:\planta\client\Help\Planta.chm"
topic = r"/D-KA-0044095.html"

Help.ShowHelp(None, helpFile, HelpNavigator.Topic, topic)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top