Sample code for 30+ languages & platforms
Delphi ActiveX

bz2 Compress File

Compress a file to the bz2 file format.

Chilkat Delphi ActiveX Downloads

Delphi ActiveX
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Integer;
bz2: TChilkatBz2;

begin
success := 0;

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

bz2 := TChilkatBz2.Create(Self);

// Compress the file qa_data/hamlet.xml to create qa_output/hamlet.bz2
success := bz2.CompressFile('qa_data/hamlet.xml','qa_output/hamlet.bz2');
if (success <> 1) then
  begin
    Memo1.Lines.Add(bz2.LastErrorText);
    Exit;
  end;

Memo1.Lines.Add('Success.');
end;