Sample code for 30+ languages & platforms
Delphi DLL

bz2 Compress File

Compress a file to the bz2 file format.

Chilkat Delphi DLL Downloads

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

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
bz2: HCkBz2;

begin
success := False;

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

bz2 := CkBz2_Create();

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

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

CkBz2_Dispose(bz2);

end;