对不起我的英语不好。
你好
我的安装程序将下载文件,通过添加“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/