Delphi Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Delphi Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
RSA Encryption
S/MIME
Socket
Spider
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Byte Array
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
SSH Key
SSH
SSH Tunnel
SFTP

Unreleased...
Bzip2
LZW
Bz2
Icon

Type Conversion

 

Article: Understanding COM References in Delphi

XML Embed Binary File

Demonstrates how to embed a binary file in XML. Also extracts binary data from XML and saves to a file.

Download Chilkat FileAccess ActiveX (freeware)

Download Chilkat XML ActiveX

uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls,
    CHILKATXMLLib_TLB,
    CHILKATFILEACCESSLib_TLB,
    OleCtrls;

...

procedure TForm1.Button1Click(Sender: TObject);
var
fileData: Array of Byte;
fac: TCkFileAccess;
xml: CHILKATXMLLib_TLB.IChilkatXml;
zipFlag: Integer;
encryptFlag: Integer;
password: String;
success: Integer;
facSuccess: Integer;

begin


//  Load a binary file from disk:
fac := TCkFileAccess.Create(Self);
fileData := fac.ReadEntireFile('dude.gif');

xml := TChilkatXml.Create(Self).ControlInterface;

xml.Tag := 'gifData';

//  If set to 1, the binary data is automatically compressed
//  before being added to the XML.  In this example, GIF data
//  is already a compressed file format, so we another layer
//  of compression doesn't really help much...
zipFlag := 0;

//  The data may be automatically 128-bit AES encrypted
//  if this flag is set to 1.
encryptFlag := 0;

password := 'NotUsed';

success := xml.SetBinaryContent(fileData,zipFlag,encryptFlag,password);

//  Examine the XML.  (The binary content is base64-encoded)
Memo1.Lines.Add(xml.GetXml());

//  Now extract the content to a file:
success := xml.SaveBinaryContent('out.gif',zipFlag,encryptFlag,password);
if (success <> 1) then
  begin
    ShowMessage(xml.LastErrorText);
  end;

//  The original data may be saved using the FileAccess component in this way:

facSuccess := fac.WriteEntireFile('original.gif', fileData);
if (facSuccess = 0) then
  begin
    ShowMessage(fac.LastErrorText);
    Exit;
  end;


end;

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Email Component · XML Parser