1

I'm including a cut-down CHM help with an installer and I want the help button on each page of the installer wizard to call up a different help page. If I open the help window from one installer wizard page by executing the command hh.exe -mapid 1234 MyAppCutDownHelp.chm it works fine, but if I do the same thing later from another wizard page with hh.exe -mapid 5678 MyAppCutDownHelp.chm I get that topic OK, but another instance of HH.EXE is started and I then have two help windows, one with topic 1234 and one with topic 5678.

I would like the first invocation of HH.exe to open the CHM help window, and from then on to have subsequent help topics display within the sane help window from the installer.

I don't believe I have access to the same HTML help API from the Inno Setup scripting Pascal that I would normally have from Delphi.

I am at present starting the help engine with

ShellExecAsOriginalUser ('open', ExpandConstant ('{tmp}\MyAppCutDownHelp.chm'), '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode) ;

but I imagine that just calls HH.exe.

Update Here is my latest attempt based on @Robert's answer:

; -- 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;
rossmcm
  • 5,493
  • 10
  • 55
  • 118

2 Answers2

3

You can use the HtmlHelpA or HtmlHelpW function in hhctrl.ocx

This is documented in 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 Love
  • 12,447
  • 2
  • 48
  • 80
  • Great @Robert. Just what I wanted. – rossmcm Jun 06 '11 at 20:56
  • @Robert aarrgghh not so fast... I get error 0xc0000005 in hhctrl.ocx - the try..except doesn't even pick it up - it goes straight to the MS "xxx has encountered an error" dialog. – rossmcm Jun 06 '11 at 23:26
  • How are you calling the function? In the example I posted it works, I have never actually done this before just wrote an example based on documentation, so I might have something to learn here as well. – Robert Love Jun 07 '11 at 00:25
  • @rossmcm, you should add your code to your _question_, not to @Robert's _answer_. – sarnold Jun 07 '11 at 01:28
  • @sarnold - well spotted - I misfired – rossmcm Jun 07 '11 at 01:45
  • The only thought that crossed my mind is that the first param is the window of the calling application. GetDesktopWindow() windows API result might be better to pass here. – Robert Love Jun 07 '11 at 02:25
  • @Robert - I've modified the "Example1.iss" in the InnoSetup package. This compiles and runs, but doesn't display any help, or give an error... does it work for you? - the code is just your answer with the rest of the script added to get it to compile. – rossmcm Jun 07 '11 at 03:56
  • I just changed Example1.iss (and modified my answer with it) When i run this on the startup it launches the CHM help file. I am using Windows 7. – Robert Love Jun 07 '11 at 04:05
  • OK @Robert just tried your example and with minor mod (changed to `C:\Program Files\` for Win XP) it behaves as yours does. Now I have find out why my other one doesn't work... Thanks – rossmcm Jun 07 '11 at 04:34
  • Ahaa! @Robert. `HtmlHelp (0, 'C:\Program Files\Inno Setup 5\ISetup.chm',HH_DISPLAY_TOC,0);` works fine, but `HtmlHelp (0, 'C:\Program Files\Inno Setup 5\ISetup.chm',HH_HELP_CONTEXT,0);` crashes out with MS error. (Context number 0 may not be valid, but I would expect it to be a bit more sociable). – rossmcm Jun 07 '11 at 05:28
1

This is much simpler IMHO:

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

No need for all that code. Just invoke the CHM file using hh.exe.

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164