开发者

Innosetup - reference a file from [Code] before the installation starts

开发者 https://www.devze.com 2023-03-06 13:26 出处:网络
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 nee

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
ShellExecAsOrig开发者_StackOverflowinalUser ('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.


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;
0

精彩评论

暂无评论...
验证码 换一张
取 消