Delphi: how to call ActiveX Functions that return an OleVariant containing a Byte Array

Some Chilkat ActiveX functions return binary data as a Variant containing a byte array.  If the Chilkat function fails, it returns an OleVariant containing an empty byte array. The following code snippet is incorrect and will cause Delphi to raise an EVariantBadIndexError exception if an empty OleVariant is returned. // This is incorrect: mybuffer : array of byte; // … […]

Delphi ActiveX Event Handling

ActiveX event callbacks can be used to get progress information for lengthy operations, especially for API calls involving communications with servers, such as FTP, SFTP (SSH), IMAP, POP3, SMTP, HTTP, etc. To use an ActiveX in Delphi, the component must be “imported”. This generates wrapper files (TLB.pas) in the “imports” directory, and may also install icons on the component palettte. […]

Cleaning up ActiveX Objects in Delphi — calling Free

When a Chilkat object is declared using “TChilkat*” such as TChilkatSFtp, and it is instantiated dynamically, then it must be explicitly freed (destroyed). The following code fragment demonstrates. If the Free method is not called, then object instances will accumulate in memory. procedure TForm1.Button1Click(Sender: TObject); var sftp: TChilkatSFtp; i: Integer; begin for i := 1 to 1000 do begin sftp […]