Well, what I have is a Python project, and now am creating an installer. I added to that the project's file .exe and a .zip file. The zip file contains .exe modules, data, etc. And its structure is like this:
example.zip:
|---project-folder:
|----here will be the files.
|----here will be the files.
What I want is to extract those files that are inside the project-folder
. So the .exe can run.
I have this code to extract a zip file:
[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.exe
unins.bat
unins.exe
example.zip
(and I want this zip file to be deleted after extracting)project-folder
(here I want the files inside the folders)app.exe
unins.bat
unins.exe
project-folder
)Refer directly to the subfolder:
SrcFldr := shellobj.NameSpace(ZipFile + '\project-folder');