Question

This is sort of a continuation of this question. I have a file that I want to include with my installation package (a .CHM help file) that I need to access during installation from code. It doesn't need to be installed to the user's machine. So I want to
- include the file in the installation package, probably uncompressed (so I guess I will do that with a [Files] ... external flag).
- reference the file during installation with code like:

procedure HelpButtonOnClick (Sender: TObject) ;   
var
    ErrorCode : Integer ;

begin
ShellExecAsOriginalUser ('open', ExpandConstant ('{???}') +  '\MyHelp.chm', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end ;

So can I reference the file before installation starts - i.e. before any files are copied to the user machine? How do I specify the path ExpandConstant ('{???}') to the file? I have a help button on the wizard form that calls the above handler.

Was it helpful?

Solution

This is easy. Just do

[Files]
Source: "MyHelp.chm"; Flags: dontcopy

[Code]

procedure HelpButtonOnClick(Sender: TObject);
var
  ErrorCode: integer;
begin
  ExtractTemporaryFile('MyHelp.chm');
  ShellExecAsOriginalUser('', ExpandConstant('{tmp}\MyHelp.chm'), '', '',
    SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top