Innosetup-在安装开始之前从[Code]中引用文件 [英] Innosetup - reference a file from [Code] before the installation starts

查看:467
本文介绍了Innosetup-在安装开始之前从[Code]中引用文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是此问题的延续一个>.我有一个要包含在我的安装包中的文件(.CHM帮助文件),在安装过程中需要从代码中访问该文件.不需要将其安装到用户的计算机上.所以我想
-将文件包含在安装包中,可能未压缩(所以我想我会使用[Files] ... external标志来做到这一点).
-在安装过程中使用以下代码引用文件:

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 ;

那么我可以在安装开始之前(即在将任何文件复制到用户计算机之前)引用文件吗?如何指定文件的路径ExpandConstant ('{???}')?我在向导表单上有一个帮助按钮,该按钮调用了上面的处理程序.

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.

推荐答案

这很容易.随便

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

这篇关于Innosetup-在安装开始之前从[Code]中引用文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆