我有一个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-A\app\folder-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.exeunins.batunins.exeexample.zip (我希望在extracting)project-folder之后删除这个压缩文件(这里我想要文件夹中的文件)我想要的:
app.exeunins.batunins.exeproject-folder)中的文件)
发布于 2021-11-25 12:18:29
直接参考子文件夹:
SrcFldr := shellobj.NameSpace(ZipFile + '\project-folder');https://stackoverflow.com/questions/70110110
复制相似问题