【发布时间】:2020-08-29 08:44:47
【问题描述】:
我来自http://www.saidsimple.com/daniel/blog/117966/ 的脚本示例,它只设置为一个 zip。我希望能够解压缩特定位置的任何拉链。我猜一种方法可能是通配符 *.zip,因为 zip 名称可能会因之前的安装程序选择而异。
不进行解压缩。我错过了定义某些东西或程序设置不正确。在我的使用中,zip 是预期程序为函数读取的文本文件。
[Setup] …
SolidCompression=true
Compression=lzma
CreateAppDir=false
DirExistsWarning=false
ShowLanguageDialog=false
CreateUninstallRegKey=no
#include <idp.iss>
[Files]
Source: "{tmp}\text.net"; DestDir: "{userappdata}\ccc"; Flags: external; Components: abc
Source: "{tmp}\HLNJ.zip"; DestDir: "{userappdata}\ccc"; Flags: external deleteafterinstall; Components: hlnj
Source: "{tmp}\HNJ.zip"; DestDir: "{userappdata}\ccc"; Flags: external deleteafterinstall; Components: hnj
[Code]
const
SHCONTCH_NOPROGRESSBOX = 4;
SHCONTCH_RESPONDYESTOALL = 16;
procedure InitializeWizard; ...
begin ...
end;
procedure CurStepChanged(CurStep: TSetupStep); ...
begin
if CurStep = ssPostInstall then
begin ...
end;
end;
procedure unzip(ZipFile, TargetFldr: PAnsiChar);
var
shellobj: variant;
ZipFileV, TargetFldrV: variant;
SrcFldr, DestFldr: variant;
shellfldritems: variant;
begin
if FileExists('{userappdata}\ccc\HLNJ.zip') then begin
ForceDirectories('{userappdata}\ccc’);
shellobj := CreateOleObject('Shell.Application');
ZipFileV := string(ZipFile);
TargetFldrV := string(TargetFldr);
SrcFldr := shellobj.NameSpace(ZipFileV);
DestFldr := shellobj.NameSpace(TargetFldrV);
shellfldritems := SrcFldr.Items;
DestFldr.CopyHere(shellfldritems, SHCONTCH_NOPROGRESSBOX or SHCONTCH_RESPONDYESTOALL);
end;
end;
procedure ExtractSomething(src, target : AnsiString);
begin
unzip(ExpandConstant(src), ExpandConstant(target));
end;
我希望其中一个拉链被解压。但什么也没有,即使在 inno log 中;这部分代码没有任何反应。至少删除 zip 作品。
编辑:我正在重新审视我去年没有解决的问题。问题是让解压缩工作。 Zip 下载到位置,但在没有先解压缩的情况下被删除。 编辑2:可能不是最好的,但似乎有效。我已将我最近的代码更改为 Inno 5 的工作版本(编辑了文件名,删除了设置。)
; #pragma include __INCLUDE__ + ";" + ReadReg(HKLM, "Software\Mitrich Software\Inno Download Plugin", "InstallDir")
#pragma include __INCLUDE__ + ";" + "c:\lib\InnoDownloadPlugin"
[Setup]
#include <idp.iss>
[Types]
Name: custom; Description: "Custom installation"; Flags: iscustom
[Components]
Name: conn; Description: “CC File”; Types: custom; Flags: exclusive
Name: hlnj; Description: “H L (Recommended)”; Types: custom; Flags: exclusive
[Files]
Source: "{tmp}\text.net"; DestDir: "{userappdata}\ccc”; Flags: external; Components: conn
Source: "{tmp}\HLNJ.zip”; DestDir: "{userappdata}\ccc”; Flags: external deleteafterinstall; Components: hlnj conn
[Code]
const
SHCONTCH_NOPROGRESSBOX = 4;
SHCONTCH_RESPONDYESTOALL = 16;
procedure InitializeWizard;
begin
idpAddFileComp('http://ccc.sourceforge.net/text.net', ExpandConstant('{tmp}\text.net'), 'conn');
idpAddFileComp('http://ccc.sourceforge.net/SecurityUpdates/HLNJ.zip', ExpandConstant('{tmp}\HLNJ.zip'), 'hlnj');
idpDownloadAfter(wpReady);
end;
procedure CurStepChanged1(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
FileCopy(ExpandConstant('{tmp}\text.net'), ExpandConstant('{userappdata}\ccc\text.net'), false);
FileCopy(ExpandConstant('{tmp}\HLNJ.zip'), ExpandConstant('{userappdata}\ccc\HLNJ.zip'), false);
end;
end;
procedure unzip(ZipFile, TargetFldr: variant);
var
shellobj: variant;
SrcFldr, DestFldr: variant;
shellfldritems: variant;
begin
if FileExists(ZipFile) then begin
if not DirExists(TargetFldr) then
if not ForceDirectories(TargetFldr) then begin
MsgBox('Can not create folder '+TargetFldr+' !!', mbError, MB_OK);
Exit;
end;
shellobj := CreateOleObject('Shell.Application');
SrcFldr := shellobj.NameSpace(ZipFile);
DestFldr := shellobj.NameSpace(TargetFldr);
shellfldritems := SrcFldr.Items;
DestFldr.CopyHere(shellfldritems, SHCONTCH_NOPROGRESSBOX or SHCONTCH_RESPONDYESTOALL);
if FileExists(TargetFldr+'\HLNJ.zip') then MsgBox('HLNJ.zip'+ZipFile+
' extracted to '+TargetFldr, mbInformation, MB_OK);
end else MsgBox('HLNJ.zip does not exist', mbError, MB_OK);
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
unzip(ExpandConstant('{userappdata}\ccc\HLNJ.zip'),ExpandConstant('{userappdata}\ccc'));
end;
end;
【问题讨论】:
-
还是一样:“你从不打电话给
ExtractSomething——你需要从CurStepChanged打电话”正如@moskito-x的答案所示。 -
@Martin Prikryl 在提供的示例中将最后一步更改为 CurStepChanged 与文件下载部分期间使用的 CurStepChanged 发生冲突。我正在努力弄清楚如何更改其中一个或另一个的过程名称,或者以另一种方式解决这个问题。
-
我已将我最近的代码更改为 Inno 5 的工作版本(编辑了文件名,删除了设置。)重要注意事项:此处使用的 Mitrich 下载插件与 Inno 6 不兼容。Inno 6 显然终于有了自己的下载能力,但我无法在网上和应用程序内找到参考如何使用它。 Inno 5 在我的小型 Win XP 上现在很好。非常感谢 moskito-x 和 Martin Prikryl。
标签: inno-setup unzip