【问题标题】:Inno Setup unzip file from input userInno Setup 从输入用户解压文件
【发布时间】:2017-08-04 11:42:26
【问题描述】:

我尝试解压缩从我的存储库下载的安装文件。我找到了这段代码:
How to get Inno Setup to unzip a file it installed (all as part of the one installation process)

但我需要在自定义页面中输入用户关于存储库中应用程序版本的信息,下载并尝试解压缩。如何将值从输入发送到ExtractMe('{tmp}\INPUT FROM USER VERSION.zip', '{app}\');

begin
  {Page for input Version}
  UserPage := CreateInputQueryPage(wpWelcome,
    'Number of Version', 'example : 1.8.20',
    'Program will download your input');
  UserPage.Add('Version:', False);
  UserPage.Values[0] := GetPreviousData('Version', '1.8.20');
end;

{Called when the user clicks the Next button}
function NextButtonClick(CurPageID: Integer): Boolean;
var
  Version: string;
  FileURL: string;
begin
  if CurPageID = wpReady then
  begin
    Version := UserPage.Values[0];
    {Download}

    FileURL := Format('http://127.0.0.1/repository/ia/ats-apps/ia-client.zip/%s/ia-client.zip-%0:s.zip', [Version]); <-- FROM HERE TO BELOW
    idpAddFile(FileURL, ExpandConstant(Format('{tmp}\%s.zip', [Version])));
    idpDownloadAfter(wpReady);
  end;
  Result := True;
end;

procedure unzip(src, target: AnsiString);
external 'unzip@files:unzipper.dll stdcall delayload';

procedure ExtractMe(src, target : AnsiString);
begin
  unzip(ExpandConstant(src), ExpandConstant(target));
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssPostInstall then 
  begin
    ExtractMe('{tmp}\INPUT FROM USER VERSION.zip', '{app}\'); <--HERE
  end;
end;

感谢提示。

【问题讨论】:

    标签: inno-setup pascalscript


    【解决方案1】:

    与您已经在NextButtonClick 中使用的方式相同:阅读UserPage.Values[0]

    ExtractMe(Format('{tmp}\%s.zip', [UserPage.Values[0]]), '{app}\');
    

    【讨论】:

    • 你是我的英雄 :) 谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-04
    相关资源
    最近更新 更多