对不起我的英语不好。
您好,我的安装程序将通过添加“ IDP:Inno安装程序的下载插件”来下载文件,但我有一个问题,因为它们以.zip格式下载,因此需要将其解压缩,无论是否可以在应用程序的位置进行解压缩?它是附加组件还是其他?请帮忙。
您可以运送所选的解压缩工具并将其用于提取。
我倾向于发布“ 7za”(7zip的命令行版本),因为我发现它的提取速度确实不错(并且比解压缩要好)。
首先,将提取工具集成到安装程序中。
[Files]
Source: ..\utils\unzip\7za.exe; DestDir: {tmp}; Flags: dontcopy
Source: and some zip files ...
注意dontcopy
。这不会在正常文件复制阶段将文件复制到用户系统,而是将文件静态编译到安装中。
其次,您可以DoUnzip
在[Code]
部分中添加一些辅助方法。
它将使用temp文件夹中的工具。
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}'));
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句