(Delphi ActiveX) Load Entire File into BinData
Demonstrates how to load an entire file into a BinData object.
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
fac: TCkFileAccess;
success: Integer;
bd: TChilkatBinData;
maxBytesToRead: Integer;
begin
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;
|