Hallo,
ich möchte meine .chm Hilfe gerne Kontextbezogen öffnen.
Zusätzlich möchte ich aber auch Fehler auswerten wie zB. 'Topic oder Hilfedatei' nicht gefunden.
Die System.Windows.Forms.Help.ShowHelp Methode gibt leider keine Fehler aus.
Deshalb möchte ich direkt über die hhctrl.ocx die Hilfe öffnen.
Mit diesem Code kann ich die Hilfe korrekt öffnen wenn Topic und die Datei vorhanden sind:
private enum HTMLHelpCommand : uint
{
HH_HELP_CONTEXT = 0x000F,
HH_GET_LAST_ERROR = 0x0014
}
[DllImport("hhctrl.ocx", SetLastError = true, EntryPoint = "HtmlHelpW", CharSet = CharSet.Unicode)]
private static extern IntPtr HtmlHelp(
IntPtr hWndCaller,
[MarshalAs(UnmanagedType.LPWStr)]
string helpFile,
HTMLHelpCommand command,
IntPtr data);
IntPtr result = HtmlHelp(
control.Handle,
path,
HTMLHelpCommand.HH_HELP_CONTEXT,
new IntPtr(topicId));
Und jetzt mein Problem: Wenn ein Fehler passiert möchte ich diesen mit HH_GET_LAST_ERROR auslesen. Leider liefert das folgende Beispiel kein Ergebnis:
[DllImport("hhctrl.ocx", SetLastError = true, EntryPoint = "HtmlHelpW", CharSet = CharSet.Unicode)]
private static extern IntPtr HtmlHelp(
IntPtr hWndCaller,
[MarshalAs(UnmanagedType.LPWStr)]
string pszFile,
HTMLHelpCommand uCommand,
[MarshalAs(UnmanagedType.LPStruct)]
HH_LAST_ERROR dwData);
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public class HH_LAST_ERROR
{
public int cbStruct = Marshal.SizeOf(typeof(HH_LAST_ERROR));
public int hr = 0;
[MarshalAs(UnmanagedType.BStr)]
public string description = "";
}
HH_LAST_ERROR lastError = new HH_LAST_ERROR();
IntPtr result1 = HtmlHelp(
control.Handle,
null,
HTMLHelpCommand.HH_GET_LAST_ERROR,
lastError);
Kann mir jemand sagen wo mein Problem liegt?
Oder gibt es überhaupt eine bessere Lösung?
Vielen Dank!