EDIT:事实证明,我描述的旧方法在某些 Windows 版本上效果不佳。它可能会弹出一个对话框窗口,而不是默默地覆盖文件。这个很容易谷歌一下:CopyHere 忽略选项 https://www.google.com/search?q=CopyHere%20ignores%20options.
新方式:
- Mitchich Inno 下载插件 https://bitbucket.org/mitrich_k/inno-download-plugin
-
7zip http://www.7-zip.org/download.html
新的方式使用7zip 独立控制台版本 http://www.7-zip.org/download.html。这是一个单一的7za.exe
,您不需要 DLL。
#include <idp.iss>
; Languages section
; Includes for Mitrich plugin's additional languages
; #include <idplang\Russian.iss>
[Files]
Source: "7za.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall;
[Run]
Filename: {tmp}\7za.exe; Parameters: "x ""{tmp}\example.zip"" -o""{app}\"" * -r -aoa"; Flags: runhidden runascurrentuser;
[Code]
procedure InitializeWizard;
begin
idpAddFile('https://example.comt/example.zip', ExpandConstant('{tmp}\example.zip'));
{ Download after "Ready" wizard page }
idpDownloadAfter(wpReady);
end;
如果您想下载,在安装开始之前解压缩并使用文件(例如,作为许可协议),我只能给出一般指导:
- 启用欢迎页面
[Setup]
: DisableWelcomePage=no
.
- Use
idpDownloadAfter(wpWelcome);
。现在它会在“欢迎”页面之后立即下载。
- 您需要一个空的许可证文件
[Setup]
: LicenseFile=license.txt
显示许可证页面。或者可能不为空,但带有“正在加载许可协议...”文本。
- 你实施
procedure CurPageChanged()
: 如果当前页面是wpLicense
然后你打电话Exec()
函数来启动 7zip 并等待它终止。没有7zip[Run]
现在部分。那么你可能会使用LoadStringFromFile()
函数从提取的文件中获取许可协议。然后将其放入UI中。大概WizardForm.LicenseMemo.RTFText = ...
应该管用。无论如何,用户界面是可访问的,如果您在设置文本时遇到困难,请就此提出单独的问题。
The 老马车方式:
- Mitchich Inno 下载插件 https://bitbucket.org/mitrich_k/inno-download-plugin
- Inno解压插件 http://www.scriptkitties.com/innounzip/
一种等效的、更干净的方式,无需unzipper.dll
is 此处描述 https://stackoverflow.com/questions/6065364/how-to-get-inno-setup-to-unzip-a-file-it-installed-all-as-part-of-the-one-inst/40706549#40706549。无论如何,它使用了 buggyCopyHere https://www.google.com/search?q=CopyHere%20ignores%20optionsWindows 功能。
#include <idp.iss>
; Languages section
; Includes for Mitrich plugin's additional languages
; #include <idplang\Russian.iss>
[Files]
Source: "unzipper.dll"; Flags: dontcopy
[Code]
procedure InitializeWizard;
begin
idpAddFile('https://example.comt/example.zip', ExpandConstant('{tmp}\example.zip'));
{ Download after "Ready" wizard page }
idpDownloadAfter(wpReady);
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
{ Extract when "Finishing installation" setup step is being performed. }
{ Extraction crashes if the output dir does not exist. }
{ If so, create it first: }
{ CreateDir(ExpandConstant(...)); }
ExtractMe('{tmp}\example.zip', '{app}\');
end;
end;
你也许可以尝试其他事情而不是wpReady
and ssPostInstall
。对于我的小拉链来说,这个效果很好。