unpacker I found what I was looking for, he should unpack the files after installation This is InnoUnzip.ZIP
My installer folder looks like this:
My code:
[Setup]
AppName=My Program
AppVersion=1.0
DefaultDirName={pf}\My Program
DisableProgramGroupPage=yes
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=userdocs:Inno Setup Examples Output
[Files]
Source: "unzipper.dll"; Flags: dontcopy
Source: "MyProg.exe"; DestDir: "{app}"
Source: "Somefile.zip"; DestDir: "{app}"; AfterInstall: ExtractMe('{app}\Somefile.zip', '{app}');
[Icons]
Name: "{commonprograms}\My Program"; Filename: "{app}\MyProg.exe"
Name: "{commondesktop}\My Program"; Filename: "{app}\MyProg.exe"
[Code]
procedure unzip(src, target: AnsiString);
external 'unzip@files:unzipper.dll stdcall delayload';
procedure ExtractMe(src, target : AnsiString); - ERROR HERE!!!!!
begin
unzip(ExpandConstant(src), ExpandConstant(target));
end;
Text error: Invalid prototype for "Extract Me"
Following up TLama's point about the redundancy of the DLL: the same effect can be achieved simply by coding UnZip()
directly within the Inno Setup script.
const
SHCONTCH_NOPROGRESSBOX = 4;
SHCONTCH_RESPONDYESTOALL = 16;
procedure Unzip(ZipFile, TargetFolder: String);
var
ShellObj, SrcFile, DestFolder: Variant;
begin
ShellObj := CreateOleObject('Shell.Application');
SrcFile := ShellObj.NameSpace(ZipFile);
DestFolder := ShellObj.NameSpace(TargetFolder);
DestFolder.CopyHere(SrcFile.Items, SHCONTCH_NOPROGRESSBOX or SHCONTCH_RESPONDYESTOALL)
end;
procedure ExtractMe(src, target : String);
begin
// Add extra application code here, then:
Unzip(ExpandConstant(src), ExpandConstant(target));
end;
The Inno Setup script code is more or less the same as the DLL's... only a bit shorter.
Be aware that if Zip or Destination folder don't exist, the NameSpace()
method calls return a Null
, the CopyHere()
fails, and the user sees a rude and baffling dialog - so best to check before calling.
Change the parameter type AnsiString to String.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With