Sample code for 30+ languages & platforms
Pascal (Lazarus/Delphi)

Open and Unzip an AES Encrypted Zip

See more Zip Examples

Open and unzip an AES encrypted Zip.

Chilkat Pascal (Lazarus/Delphi) Downloads

Pascal (Lazarus/Delphi)
program ChilkatDemo;

// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  SysUtils,
  CkDllLoader,
  Chilkat.Zip;

// ---------------------------------------------------------------------------

procedure RunDemo;
var
  success: Boolean;
  zip: TZip;
  unzipCount: Integer;

begin
  success := False;

  //  This example requires the Chilkat API to have been previously unlocked.
  //  See Global Unlock Sample for sample code.

  zip := TZip.Create;

  success := zip.OpenZip('/myZips/aes.zip');
  if (success <> True) then
    begin
      WriteLn(zip.LastErrorText);
      Exit;
    end;

  //  Set the password needed to unzip.
  //  This password must match the password used when the zip
  //  was created.
  zip.DecryptPassword := 'myPassword';

  //  Unzip the .zip into /unzipDir.   
  //  Returns the number of files and directories unzipped.
  unzipCount := zip.Unzip('/unzipDir/');
  if (unzipCount < 0) then
    begin
      WriteLn(zip.LastErrorText);
    end
  else
    begin
      WriteLn('Success!');
    end;


  zip.Free;

end;

// ---------------------------------------------------------------------------

begin

  try
    RunDemo;
  except
    on E: Exception do
      WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
  end;

  WriteLn;
  {$IFDEF MSWINDOWS}
  WriteLn('Press Enter to exit...');
  ReadLn;
  {$ENDIF}
end.