4

I have an installation file for my app and it contains the .exe file and a .zip file as well.

What I want is:

Recently I added a code in the [Code] section that is extracting files from zip, But actually, it happened after the installation is done, and the progress bar is 100%, So what I want is to make that code's (unzipping) process work with the progress bar and show the user what is extracting at the moment.

For example: let's say extracting files will take 50% of the progress bar and the rest will take it the code section while it is unzipping, with the state about what is extracting at the moment.

Here is the code:

[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;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Uncle Bob
  • 155
  • 8

1 Answers1

5

The easiest solution is to use the WizardForm.StatusLabel:

WizardForm.StatusLabel.Caption := 'Extracting...';

enter image description here


For more fancy solution you can use TOutputProgressWizardPage. For an example that even displays a progress bar (though by using a DLL for the extraction), see:
Inno Setup - How to add cancel button to decompressing page?

This post lists more related examples:
Inno Setup: How to modify long running script so it will not freeze GUI?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992