Inno Setup 中的条件文件复制

Conditional file copy in Inno Setup

我想制作一个条件文件 copy/installation,具体取决于位于 {app} 位置的给定 .cfg(文本)文件中的内容。该文件包含一个 URL 内部,URL 看起来像这样:“update.website.eu”,或这个“update.website.com”,或“update.worldoftanks.kr”,但可以是还有 "update.worldoftanks.kr/" 等等,有几种可能性。所以我需要一种机制来检测 url 并让我为每个检测到的 url.

安装不同的文件

目前我有这样的例子,但由于我不是高级程序员(我或多或少知道一些基础知识),我需要一个很好的例子。

if (CurPageID = wpPreparing) then
begin
  client_ver :=
    LoadValueFromXML(ExpandConstant('{app}\file.cfg'),
    '//info/patch_info_urls/item');
  if client_ver = 'http://update.website.eu/' then
    if MsgBox('Are you sure?', mbConfirmation, MB_OKCANCEL) = IDCANCEL then
      Result:=False;
end;

file.cfg的例子:

<?xml version="1.0" encoding="UTF-8"?>
<info version="3.1">
    <!-- ... -->
    <patch_info_urls>
        <item>http://update.website.eu/</item>
    </patch_info_urls>
</info>

无论如何我想在 [Files] 部分使用它,是否可以从那里触发它,调用 [Files] 中的过程或其他东西?

我试了几次,但在编译过程中它总是给我一些不匹配的错误。

ps。忽略 MsgBox,这只是示例,我不会显示类似的内容。我只需要复制文件。

使用Check parameter:

[Files]
Source: "file_for_url1"; DestDir: "{app}"; Check: IsURl1
Source: "file_for_url2"; DestDir: "{app}"; Check: IsURl2
[Code]

var
  ClientVer: string;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssInstall then
  begin
    ClientVer :=
      LoadValueFromXML(ExpandConstant('{app}\file.cfg'), 
      '//info/patch_info_urls/item');
    Log(Format('Client version is %s', [ClientVer]));
  end;
end;

function IsUrl1: Boolean;
begin
  Result := (ClientVer = 'http://update.website.eu/');
end;

function IsUrl2: Boolean;
begin
  Result := (ClientVer = 'http://update.website.com/');
end;