如何使用Inno Setup提取ZIP文件中文件夹中的文件



好吧,我有一个Python项目,现在正在创建一个安装程序。我添加了该项目的.exe文件和.zip文件。zip文件包含.exe模块、数据等。其结构如下:

example.zip:
|---project-folder:
|----here will be the files.
|----here will be the files.

我想要的是提取project-folder中的那些文件。这样.exe就可以运行了。我有这个代码来提取一个zip文件:

[Code]

procedure InitializeWizard;
begin
ForceDirectories(ExpandConstant('{localappdata}folder-Aappfolder-B'))
end;
const
SHCONTCH_NOPROGRESSBOX = 4;
SHCONTCH_RESPONDYESTOALL = 16;
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);
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then 
begin
unzip(ExpandConstant('{app}example.zip'),ExpandConstant('{app}'));
end;
end;

结果:

  • app.exe
  • unins.bat
  • unins.exe
  • example.zip(我希望这个zip文件在提取后被删除(
  • project-folder(这里我想要文件夹中的文件(

我想要什么:

  • app.exe
  • unins.bat
  • unins.exe
  • 文件。。。(project-folder内部的文件(

直接引用子文件夹:

SrcFldr := shellobj.NameSpace(ZipFile + 'project-folder');

最新更新