Sample code for 30+ languages & platforms
Delphi ActiveX

Load Entire File into BinData

Demonstrates how to load an entire file into a BinData object.

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;
fac: TCkFileAccess;
bd: TChilkatBinData;
maxBytesToRead: Integer;

begin
success := 0;

fac := TCkFileAccess.Create(Self);

success := fac.OpenForRead('qa_data/pdf/sample.pdf');
if (success = 0) then
  begin
    Memo1.Lines.Add(fac.LastErrorText);
    Exit;
  end;

bd := TChilkatBinData.Create(Self);
maxBytesToRead := 99999999;
success := fac.FileReadBd(maxBytesToRead,bd.ControlInterface);
if (success = 0) then
  begin
    Memo1.Lines.Add(fac.LastErrorText);
    Exit;
  end;

fac.FileClose();

// The bd object contains the file data...
success := bd.WriteFile('qa_output/sample.pdf');
end;