The Blog of Daniel

Just my place to write without any delusions of self-importance.

How to get Inno Setup to unzip a file it installed.

A while back I posted C source code for a DLL and examples for extracting ZIP files from within an Inno Setup installer.  It was overkill.  There is no need to use any external DLL file with Inno Setup to extract a ZIP file to a given directory.  Just add this snippet to your ISS file, right below the code section.

If you find this of use, or even if you just find it at all, please drop a comment below.

[Code]

procedure unzip(ZipFile, TargetFldr: PAnsiChar);
var
shellobj: variant;
ZipFileV, TargetFldrV: variant;
SrcFldr, DestFldr: variant;
shellfldritems: variant;
begin
if FileExists(ZipFile) then begin
ForceDirectories(TargetFldr);
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;
More Posts by Daniel