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

Tre*_*vor 1 delphi chm delphi-xe

我可以通过传递一个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..
Run Code Online (Sandbox Code Playgroud)


致电获取帮助通过我的身份证

GetHelp(Address_File); //call get help pass my ID to open to the Address_File topic
Run Code Online (Sandbox Code Playgroud)


GetHelp程序

procedure GetHelp(HelpID : Word);
begin
  Application.HelpFile := ProgramPath + 'help.chm';
  HtmlHelpW(0, PWideChar(Application.HelpFile),HH_HELP_CONTEXT , HelpID);
end;
Run Code Online (Sandbox Code Playgroud)


HtmlHelpW函数

function HtmlHelpW(hwndCaller : HWND; pszFile: PWideChar; uCommand : Integer;
         dwData : DWORD) : HWND; stdcall; external 'hhctrl.ocx' name 'HtmlHelpW';
Run Code Online (Sandbox Code Playgroud)

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

Mar*_*ort 6

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)
Run Code Online (Sandbox Code Playgroud)

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

util在最近的版本中(确保你得到2.6.0)并且也可以在Free Pascal源代码中使用,它应该可以通过相对较小的努力转换为Delphi.

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