Inno setup 如何在安装后使用InnoTools解压多个文件?
我来自的脚本示例,它只针对一个zip设置。我想能够解压任何拉链在一个特定的位置。我想其中一种方法可能是通配符*.zip,因为zip名称可能会根据早期安装程序的选择而有所不同 没有解压缩发生。我错过了定义某些内容或程序设置不正确。在我的使用中,ZIP是预期程序为函数读取的文本文件Inno setup 如何在安装后使用InnoTools解压多个文件?,inno-setup,unzip,Inno Setup,Unzip,我来自的脚本示例,它只针对一个zip设置。我想能够解压任何拉链在一个特定的位置。我想其中一种方法可能是通配符*.zip,因为zip名称可能会根据早期安装程序的选择而有所不同 没有解压缩发生。我错过了定义某些内容或程序设置不正确。在我的使用中,ZIP是预期程序为函数读取的文本文件 [Setup] … SolidCompression=true Compression=lzma CreateAppDir=false DirExistsWarning=false ShowLanguageDialog=
[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;
[设置]…
SolidCompression=true
压缩=lzma
CreateAppDir=false
direxistswaning=false
ShowLanguageDialog=false
CreateUninstallRegKey=否
#包括
[档案]
资料来源:“{tmp}\text.net”;DestDir:“{userappdata}\ccc”;旗帜:外部;组成部分:abc
资料来源:“{tmp}\HLNJ.zip”;DestDir:“{userappdata}\ccc”;标志:外部删除后安装;组件:hlnj
资料来源:“{tmp}\HNJ.zip”;DestDir:“{userappdata}\ccc”;标志:外部删除后安装;组成部分:hnj
[守则]
常数
SHCONTCH_NOPROGRESSBOX=4;
SHCONTCH_respondendyestall=16;
过程初始化Wizard。。。
开始
终止
过程CurStepChanged(CurStep:TSetupStep)。。。
开始
如果CurStep=ssPostInstall,则
开始
终止
终止
程序解压缩(ZipFile,TargetFldr:PAnsiChar);
变量
shellobj:变体;
ZipFileV,TargetFldrV:变体;
SrcFldr,DestFldr:变体;
贝壳类:变种;
开始
如果文件存在(“{userappdata}\ccc\HLNJ.zip”),则开始
强制目录({userappdata}\ccc');
shellobj:=CreateOleObject('Shell.Application');
ZipFileV:=字符串(ZipFile);
TargetFldrV:=字符串(TargetFldr);
SrcFldr:=shellobj.NameSpace(ZipFileV);
DestFldr:=shellobj.NameSpace(TargetFldrV);
shellfldritems:=SrcFldr.项目;
在此处删除复制文件(外壳驱动项、SHCONTCH\u NOPROGRESSBOX或SHCONTCH\u RespondeYesToall);
终止
终止
程序(src,目标:AnsiString);
开始
解压(ExpandConstant(src),ExpandConstant(target));
终止
我希望其中一个拉链能拉开。但什么都没有,即使是在inno log中;在这段代码中没有发生任何事情。至少删除了zip作品
编辑:我正在重温一个我去年没有解决的问题。问题是如何让解压生效。Zip下载到该位置,但未首先解压缩就被删除。
编辑2:可能不是最好的,但似乎有效。我已将最近的代码更改为Inno 5的工作版本(编辑了文件名,删除了安装程序)
#pragma include uuuu include uuu+“;”+ReadReg(HKLM,“软件\Mitrich软件\Inno下载插件”,“安装目录”)
#pragma include uuu include uuu+“;”+“c:\lib\InnoDownloadPlugin”
[设置]
#包括
[类型]
名称:海关;说明:“自定义安装”;旗帜:iscustom
[组成部分]
姓名:康宁;;说明:“抄送文件”;类型:海关;旗帜:独家
姓名:hlnj;说明:“HL(推荐)”;类型:海关;旗帜:独家
[档案]
资料来源:“{tmp}\text.net”;DestDir:“{userappdata}\ccc”;标志:外部;组件:conn
资料来源:“{tmp}\HLNJ.zip”;DestDir:“{userappdata}\ccc”;标志:外部deleteafterinstall;组件:hlnj conn
[守则]
常数
SHCONTCH_NOPROGRESSBOX=4;
SHCONTCH_respondendyestall=16;
程序初始化;
开始
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);
终止
程序CurStepChanged1(CurStep:TSetupStep);
开始
如果CurStep=ssPostInstall,则
开始
FileCopy(ExpandConstant({tmp}\text.net')、ExpandConstant({userappdata}\ccc\text.net')、false);
FileCopy(ExpandConstant({tmp}\HLNJ.zip')、ExpandConstant({userappdata}\ccc\HLNJ.zip')、false);
终止
终止
程序解压缩(ZipFile,TargetFldr:variant);
变量
shellobj:变体;
SrcFldr,DestFldr:变体;
贝壳类:变种;
开始
如果存在文件(ZipFile),则开始
如果不存在(TargetFldr),则
如果没有强制目录(TargetFldr),则开始
MsgBox('无法创建文件夹'+TargetFldr+'!!',mbError,MB_OK);
出口
终止
shellobj:=CreateOleObject('Shell.Application');
SrcFldr:=shellobj.NameSpace(ZipFile);
DestFldr:=shellobj.NameSpace(TargetFldr);
shellfldritems:=SrcFldr.项目;
在此处删除复制文件(外壳驱动项、SHCONTCH\u NOPROGRESSBOX或SHCONTCH\u RespondeYesToall);
如果存在文件(TargetFldr+'\HLNJ.zip'),则MsgBox('HLNJ.zip'+ZipFile+
'提取到'+TargetFldr,MB信息,MB_OK);
end else MsgBox('HLNJ.zip不存在',mbError,MB_OK);
终止
过程CurStepChanged(CurStep:TSetupStep);
开始
如果CurStep=ssPostInstall,则
开始
解压(ExpandConstant({userappdata}\ccc\HLNJ.zip')、ExpandConstant({userappdata}\ccc');
终止
终止
您甚至无法提取一个.zip文件。
所以,一步一步地,第一个,然后
代码不完整。
因此,人们只能猜测遗漏了什么或错了什么
要测试unzip
程序的正常功能,您应该使用一个简单的标准inno设置程序
如果这样做有效,您可以添加额外的功能,然后更容易发现错误
此外,使用的常量“src”和“target”不可见。
它们是如何建造的
unzip(ExpandConstant(src), ExpandConstant(target));
应避免使用不同类型的数据
AnsiString vs PAnsiChar
procedure unzip(ZipFile, TargetFldr: PAnsiChar);
....
end;
procedure ExtractSomething(src, target : AnsiString);
begin
unzip(ExpandConstant(src), ExpandConstant(target));
end;
我怀疑{tmp}的使用将由#includeidp.iss
下载来实现。
此代码也不存在
我们将模拟这种情况,并使用已知目录中的已知zip文件。因此,我们不需要下载这些文件
信息也不会造成伤害,但更容易发现故障。为此,我使用了一些MsgBox() 下面是一个简单的步骤。
- 将HLNJ.zip文件复制到C:\HLNJ.zip
并查找
HLNJ.zip的文件或文件夹名部分 所以我们可以测试提取
- 我在这里使用一个文件
procedure unzip(ZipFile, TargetFldr: PAnsiChar); .... end; procedure ExtractSomething(src, target : AnsiString); begin unzip(ExpandConstant(src), ExpandConstant(target)); end;
[Files] ; Simulate the download of HLNJ.zip is ok ; On the development PC .. on the client PC. Source: "C:\HLNJ.zip"; DestDir: "{tmp}"; ; Now "HLNJ.zip" is in the {tmp} folder so we can use it. Source: "{tmp}\HLNJ.zip"; DestDir: "{userappdata}\ccc"; Flags: external deleteafterinstall [Code] const SHCONTCH_NOPROGRESSBOX = 4; SHCONTCH_RESPONDYESTOALL = 16; .... procedure unzip(ZipFile, TargetFldr: variant);// <--- variant instead of PAnsiChar 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+'\atext.txt') then MsgBox('ZipFile '+ZipFile+ ' extracted to '+TargetFldr, mbInformation, MB_OK); end else MsgBox('ZipFile '+ZipFile+' 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\extracted')); end; end;