如何解决安装后解压缩 zip 和 7z 文件,然后删除它们,但保留提取的内容完整?
我使用的是 Inno Setup 6.1.2。我制作了一个从 Internet 下载 zip 和 7z 文件的安装程序,安装后应该将它们解压缩到 {app} 目录,最后删除 zip 和 7z 文件,同时保持提取的内容完整。>
问题是,它不解压缩文件,只是将它们下载到 {app} 目录。我试过使用 deleteafterinstall
标志,但它只是删除 zip 和 7z 文件,结果仅下载非外部文件。
我希望安装程序在将 zip 和 7z 文件解压缩到特定目录后删除它们。我该怎么做?
代码如下:
[Setup]
DefaultDirName=C:\Program Files (x86)\example
disableDirPage=no
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
Privilegesrequired=admin
PrivilegesrequiredOverridesAllowed=commandline
OutputDir=C:\example1\Output
OutputBaseFilename=test
SolidCompression=yes
Compression=lzma
WizardStyle=modern
[Files]
Source: "{src}\example2.7z"; DestDir: "{app}"; Flags: external
Source: "C:\a\b.ini"; DestDir: "{app}\example2\something1"; Flags: ignoreversion recursesubdirs
Source: "{src}\example3.7z"; DestDir: "{app}\example2\something1"; Flags: external
[Code]
var
DownloadPage: TDownloadWizardPage;
function OnDownloadProgress(const Url,FileName: String; const Progress,ProgressMax: Int64): Boolean;
begin
if Progress = ProgressMax then
Log(Format('Successfully downloaded files to {app}: %s',[FileName]));
Result := True;
end;
procedure InitializeWizard;
begin
DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing),SetupMessage(msgPreparingDesc),@OnDownloadProgress);
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
if CurPageID = wpReady then begin
DownloadPage.Clear;
DownloadPage.Add('https://example.com/example2.7z','example2.7z','');
DownloadPage.Add('https://example.com/example3','example3.7z','');
DownloadPage.Show;
try
try
DownloadPage.Download; // This downloads the files to {app}
Result := True;
except
SuppressibleMsgBox(AddPeriod(GetExceptionMessage),mbCriticalError,MB_OK,IDOK);
Result := False;
end;
finally
DownloadPage.Hide;
end;
end else
Result := True;
end;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。