【问题标题】:Jumping to a topic in a CHM help file without opening another window在不打开另一个窗口的情况下跳转到 CHM 帮助文件中的主题
【发布时间】:2011-06-05 23:30:49
【问题描述】:

我在安装程序中包含一个精简的 CHM 帮助,我希望安装程序向导的每个页面上的帮助按钮都能调出不同的帮助页面。如果我通过执行命令hh.exe -mapid 1234 MyAppCutDownHelp.chm 从一个安装程序向导页面打开帮助窗口,它可以正常工作,但如果我稍后从另一个向导页面使用hh.exe -mapid 5678 MyAppCutDownHelp.chm 执行相同的操作,我会得到该主题,但另一个 HH 实例。 EXE 启动,然后我有两个帮助窗口,一个主题为 1234,一个主题为 5678。

我希望第一次调用 HH.exe 以打开 CHM 帮助窗口,然后在安装程序的正常帮助窗口中显示后续帮助主题。

我不相信我可以从 Inno Setup 脚本 Pascal 访问相同的 HTML 帮助 API,而我通常会从 Delphi 获得。

我目前正在使用

启动帮助引擎
ShellExecAsOriginalUser ('open', ExpandConstant ('{tmp}\MyAppCutDownHelp.chm'), '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode) ;

但我想这只是调用 HH.exe。

更新这是我根据@Robert 的回答的最新尝试:

; -- Help Test.iss --

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
Compression=lzma2
SolidCompression=yes
OutputDir=userdocs:Inno Setup Examples Output

[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme

[Icons]
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"

[Code]

const
 HH_DISPLAY_TOPIC = 0;
 HH_DISPLAY_TOC =1;
 HH_DISPLAY_INDEX =2;
 HH_HELP_CONTEXT = 15;

function HtmlHelpA (hWndCaller: HWND; pszFile: PAnsiChar; uCommand: UINT; dwData: DWORD): HWnd; 
  external 'HtmlHelpA@hhctrl.ocx stdcall';

function HtmlHelp(hWndCaller: HWND; pszFile: String; uCommand: UINT; dwData: DWORD): HWnd; 
begin
  try
    result := HtmlHelpA(hWndCaller,pszFile,uCommand,dwData);
  except
     MsgBox('Unable To Display Help file.', mbError, MB_OK);    
  end;
end;


function InitializeSetup : Boolean;
begin
  HtmlHelp(0,'MyProg.chm',HH_DISPLAY_TOC,0);
  result := true;

end;

【问题讨论】:

  • 使用你的代码我什么也得不到。找不到“Myprog.chm”。不过我没有收到错误消息。

标签: inno-setup chm shellexecute html-help


【解决方案1】:

您可以在hhctrl.ocx 中使用HtmlHelpAHtmlHelpW 函数

这在MSDN 中有记录。

; -- Example1.iss --
; Demonstrates copying 3 files and creating an icon.

; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES!

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
Compression=lzma2
SolidCompression=yes
OutputDir=userdocs:Inno Setup Examples Output

[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme

[Icons]
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"

[Code]
const
 HH_DISPLAY_TOPIC = 0;
 HH_DISPLAY_TOC =1;
 HH_DISPLAY_INDEX =2;
 HH_HELP_CONTEXT = 15;

function HtmlHelpA (hWndCaller: HWND; pszFile: PAnsiChar; uCommand: UINT; dwData: DWORD): HWnd; 
  external 'HtmlHelpA@hhctrl.ocx stdcall';

function HtmlHelp(hWndCaller: HWND; pszFile: String; uCommand: UINT; dwData: DWORD): HWnd; 
begin
  try
    result := HtmlHelpA(hWndCaller,pszFile,uCommand,dwData);
  except
     MsgBox('Unable To Display Help file.', mbError, MB_OK);    
  end;
end;


function InitializeSetup : Boolean;
begin
  HtmlHelp(0,'C:\Program Files (x86)\Inno Setup 5\ISetup.chm',HH_DISPLAY_TOC,0);
  result := true;
end;

【讨论】:

  • 太棒了@罗伯特。正是我想要的。
  • @Robert aarrgghh 没那么快...我在 hhctrl.ocx 中收到错误 0xc0000005 - try..except 甚至没有捡起它 - 它直接进入 MS “xxx 遇到了一个错误”对话框。
  • 你是如何调用函数的?在我发布的示例中它是有效的,我之前从未真正这样做过,之前只是根据文档编写了一个示例,所以我可能在这里也有一些东西要学习。
  • @rossmcm,您应该将代码添加到您的question,而不是@Robert 的answer
  • @sarnold - 很好发现 - 我打错了
【解决方案2】:

恕我直言,这要简单得多:

Filename: "{win}\hh.exe"; \
    Parameters: "{app}\MeetSchedAssist.chm::/msa-revision-history.htm"; \
    WorkingDir: "{app}"; \
    Flags: nowait postinstall runmaximized; \
    Description: "{cm:ViewChangeHistory}"

不需要所有的代码。只需使用hh.exe 调用 CHM 文件。

【讨论】:

  • 我认为这不符合要求“无需打开另一个窗口”,或者是吗?
  • @DocBrown 不知道!我在 4 年前写了这个答案。
猜你喜欢
  • 2015-08-06
  • 2017-03-10
  • 1970-01-01
  • 2016-08-18
  • 1970-01-01
  • 1970-01-01
  • 2014-08-31
  • 1970-01-01
相关资源
最近更新 更多