Inno Setup提示您输入外部文件 [英] Inno Setup Prompt for external file location
问题描述
我当前使用[Files] Flags: external
将用户数据导入到我的安装中,正在运行.
I currently use [Files] Flags: external
to import user data into my installation, which is working.
我现在需要在安装过程中提示您输入特定的外部文件.
I now need to prompt for a specific external file during the installation.
用例:
我们安装需要许可证文件的软件(请勿与许可证协议混淆).我想提示用户输入他们的许可证文件.他们提供文件后,会将其复制到DestDir
.
Use case:
We install software that requires a license file (not to be confused with the license agreement). I want to prompt the user for their license file. Once they provide a file, it would be copied to the DestDir
.
我正在寻找类似[Files] Flags: PromptForFile
之类的东西或实现相同目的的例程.有人已经解决了吗?
I'm looking for a something like [Files] Flags: PromptForFile
or a routine that achieves the same. Has someone already solved this?
推荐答案
使用 CreateInputFilePage
函数转到创建自定义向导页面,以提示用户输入许可证文件.
Use the CreateInputFilePage
function to a create custom wizard page to prompt a user for the license file.
然后,使用脚本常量,将所选路径用作[Files]
部分中的源路径.
Then, use a scripted constant to use the selected path as a source path in the [Files]
section.
[Files]
Source: "{code:GetLicensePath}"; DestDir: "{app}"; Flags: external
[Code]
var
LicenseFilePage: TInputFileWizardPage;
procedure InitializeWizard();
begin
LicenseFilePage :=
CreateInputFilePage(
wpSelectDir,
'Select License File Location',
'Where is your license file located?',
'Select where License file is located, then click Next.');
LicenseFilePage.Add(
'Location of license file:',
'License files|*.lic|All files|*.*',
'.lic');
end;
function GetLicensePath(Param: string): string;
begin
Result := LicenseFilePage.Values[0];
end;
TODO:您需要以某种方式处理用户没有选择任何许可证文件的情况.要么不允许继续(请使用 NextButtonClick
)或跳过文件安装(使用 Check
参数).
TODO: You need to handle somehow a situation, when a user does not select any license file. Either don't allow to proceed (use the NextButtonClick
) or skip the file installation (use the Check
parameter).
这篇关于Inno Setup提示您输入外部文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!