Delphi HtmlHelpAPI-如何指导 CHM 文件打开到不同的部分

标签 delphi delphi-xe chm

我可以通过传递 ShortInteger 并将其转换为 dwData 参数的 Word 来打开 CHM 文件。 IE。

Unit Help;   //this is where the Id's are set with their description
 Interface
 Const

Address_File = 35;  //delphi identifies Address_File as a shortint
etc..

调用获取帮助传递我的 ID
GetHelp(Address_File); //call get help pass my ID to open to the Address_File topic

获取帮助程序
procedure GetHelp(HelpID : Word);
begin
  Application.HelpFile := ProgramPath + 'help.chm';
  HtmlHelpW(0, PWideChar(Application.HelpFile),HH_HELP_CONTEXT , HelpID);
end;

HtmlHelpW 函数
function HtmlHelpW(hwndCaller : HWND; pszFile: PWideChar; uCommand : Integer;
         dwData : DWORD) : HWND; stdcall; external 'hhctrl.ocx' name 'HtmlHelpW';

当我传递不同的 ShortIntegers 时,我可以在不同的部分初始化帮助文件。
但是我无法弄清楚这些值是如何映射的。 chm 文件中有一些我希望能够映射到的部分,但与它们关联的短整数或上下文 ID 未记录在程序中或未映射。

最佳答案

Free Pascal 带有一个 chmls.exe 实用程序,它有一个尝试恢复别名(上下文)数据的命令:

chmls, a CHM utility. (c) 2010 Free Pascal core.

Usage: chmls [switches] [command] [command specific parameters]

Switches :
 -h, --help     : this screen
 -p, --no-page  : do not page list output
 -n,--name-only : only show "name" column in list output

Where command is one of the following or if omitted, equal to LIST.
 list       <filename> [section number]
            Shows contents of the archive's directory
 extract    <chm filename> <filename to extract> [saveasname]
            Extracts file "filename to get" from archive "filename",
            and, if specified, saves it to [saveasname]
 extractall <chm filename> [directory]
            Extracts all files from archive "filename" to directory
            "directory"
 unblockchm <filespec1> [filespec2] ..
            Mass unblocks (XPsp2+) the relevant CHMs. Multiple files
            and wildcards allowed
 extractalias <chmfilename> [basefilename] [symbolprefix]
            Extracts context info from file "chmfilename"
            to a "basefilename".h and "basefilename".ali,
            using symbols "symbolprefix"contextnr
 extracttoc <chmfilename> [filename]
            Extracts the toc (mainly to check binary TOC)
 extractindex <chmfilename> [filename]
            Extracts the index (mainly to check binary index)

这可能是一个开始,因为至少您会知道哪些页面是使用 ID 导出的,并且 URL 名称可能会提供一些信息。

该实用程序在最近的版本中(确保您获得 2.6.0)并且在 Free Pascal 源代码中也可用,它应该可以通过相对较小的努力转换为 Delphi。

基本上,chmls 工具是由各种测试代码库创建的。测试程序反编译和打印不同 CHM 部分的内容,并在创建帮助文件编译器 chmcmd 时使用,它也是 FPC 的一部分。

关于Delphi HtmlHelpAPI-如何指导 CHM 文件打开到不同的部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13279485/

相关文章:

delphi - Delphi导入组件-类型库与ActiveX

xml - 如何创建xmlns :xsi and xsd information in an XML document

text - CHM格式的替代品?

Android TListBox 滚动不流畅

Delphi、VirtualStringTree - 处理简单的文本样式(如 bbcode)

delphi - 自定义绘制 TAction 下拉菜单

java - 如何在 Java Swing 应用程序中打包和运行 Windows 帮助 (.chm) 文件

chm - 为什么我的CHM文件搜索功能报 "No topics found"?

delphi - 免注册 COM/DLL?

delphi - 仅用图像制作按钮的最简单方法