inno-setup - 下载带有 IDP : Download plugin for Inno Setup, 的 .zip 文件并解压它们

标签 inno-setup pascalscript inno-download-plugin

对不起我的英语不好。

你好
我的安装程序将下载文件,通过添加“IDP:Inno Setup的下载插件”,我有一个问题,因为它们以.zip格式下载,因此需要解压缩,是否可以解压应用程序在哪里?它是一个附加组件还是什么?
请帮忙。

最佳答案

您可以提供您选择的解压缩工具并将其用于提取。

我倾向于发布“7za”(7zip 的命令行版本),因为我发现它的提取速度非常好(并且比解压缩更好)。

首先,您将提取工具集成到安装程序中。

    [Files]
    Source: ..\utils\unzip\7za.exe; DestDir: {tmp}; Flags: dontcopy
    Source: and some zip files ...

请注意 dontcopy .这不会在正常的文件复制阶段将文件复制到用户系统,而是将文件静态编译到安装中。

其次,你可以加一点DoUnzip您的 [Code] 的辅助方法部分。

它将使用临时文件夹中的工具。
procedure DoUnzip(source: String; targetdir: String);
var 
    unzipTool: String;
    ReturnCode: Integer;
begin
    // source contains tmp constant, so resolve it to path name
    source := ExpandConstant(source);

    unzipTool := ExpandConstant('{tmp}\7za.exe');

    if not FileExists(unzipTool)
    then MsgBox('UnzipTool not found: ' + unzipTool, mbError, MB_OK)
    else if not FileExists(source)
    then MsgBox('File was not found while trying to unzip: ' + source, mbError, MB_OK)
    else begin
         if Exec(unzipTool, ' x "' + source + '" -o"' + targetdir + '" -y',
                 '', SW_HIDE, ewWaitUntilTerminated, ReturnCode) = false
         then begin
             MsgBox('Unzip failed:' + source, mbError, MB_OK)
         end;
    end;
end;

第三,您提取解压缩工具,然后是 zip,然后您只需在 zip 上使用 DoUnzip() 方法。 这些命令用于 [Code]部分。
  // extract 7za to temp folder
  ExtractTemporaryFile('7za.exe');

  // extract the zip to the temp folder (when included in the installer)
  // skip this, when the file is downloaded with IDP to the temp folder
  //ExtractTempraryFile('app.zip);

  targetPath := ExpandConstant('{tmp}\');

  // unzip the zip in the tempfolder to your application target path
  DoUnzip(targetPath + 'app.zip', ExpandConstant('{app}'));

关于inno-setup - 下载带有 IDP : Download plugin for Inno Setup, 的 .zip 文件并解压它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29462004/

相关文章:

windows - 如何在 Pascal Script/Inno Setup 中使用 WinAPI 中的 PathCombine()?

inno-setup - 合并不同来源的事件函数(InitializeWizard)实现

inno-setup - Inno 设置 : TInputOptionWizardPage disabled radio buttons look partially enabled (bug? )

inno-setup - Inno Setup 将数组中的字符串转换为 bool 值

installation - 在 Inno Setup 的代码部分中下载程序后运行该程序

inno-setup - 安装开始前 Inno Setup : Download setup . bin 切片文件

inno-setup - 在 Inno 下载插件中自定义 "Downloading"消息

postgresql - 将 Inno Setup exec 函数中的命令传递到 pgsql 数据库中

inno-setup - Inno Setup 中较大的 "Select Components"页面

inno-setup - 如何在设置安装中绕过/禁用 UAC