2016-12-05 193 views
3

我目前使用[Files] Flags: external将用户数据导入到正在工作的安装中。Inno Setup外部文件位置提示

我现在需要在安装过程中提示输入特定的外部文件。

使用案例:
我们安装需要许可证文件的软件(不要与许可证协议混淆)。我想提示用户输入他们的许可证文件。一旦他们提供了一个文件,它将被复制到DestDir

我正在寻找像[Files] Flags: PromptForFile或实现相同的例程。有人已经解决了这个问题?

回答

2

使用CreateInputFilePage function创建自定义向导页面来提示用户输入许可证文件。

然后,使用scripted constant将所选路径用作[Files]部分中的源路径。

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

License file page


TODO:你需要以某种方式处理的情况下,当用户不选择任何许可文件。请不要继续(使用NextButtonClick)或跳过文件安装(使用Check parameter)。