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

Create Self-Extractor with Advanced Options

Download Chilkat Zip ActiveX

Delphi example code showing how to create a self-extracting executable with advanced options.

// Create a self-extracting EXE with customization:
// 1) A custom icon
// 2) Run a setup program packaged in the .exe immediately after extraction.
// 3) Customize the dialog title
// 4) Encrypt the .exe so that it requires a password to extract.
// 5) Hard code an absolute unzip directory, allowing the .exe to run without a user interface.
// 6) Unzip to an auto-selected temp directory.

procedure TForm1.Button14Click(Sender: TObject);
var
  recurse: Integer;
  success: Integer;

begin
  // UnlockComponent should be called once at the beginning of a program.
  ChilkatZip21.UnlockComponent('anything for 30-day trial');

  // Initialize the zip object.
  ChilkatZip21.NewZip('xyz.zip');

  recurse := 1;
  ChilkatZip21.AppendFiles('c:/temp/xyz/*', recurse);

  {
    The directory tree on disk looks like this:

C:\temp\xyz\dudeA.gif
C:\temp\xyz\setup.exe
C:\temp\xyz\b\
C:\temp\xyz\b\dudeAbc.gif
C:\temp\xyz\b\dudeXyz.gif
C:\temp\xyz\b\setup1.exe
C:\temp\xyz\b\123\
C:\temp\xyz\b\123\dude123.gif
C:\temp\xyz\b\123\test.txt

    The directory tree in the zip object looks like this:

dudeA.gif
setup.exe
b\
b\dudeAbc.gif
b\dudeXyz.gif
b\setup1.exe
b\123\
b\123\dude123.gif
b\123\test.txt

  }

  // Run setup1.exe immediately after the EXE self-extracts:
  ChilkatZip21.AutoRun := 'b\setup1.exe';
  // Chilkat provides a test setup.exe at this URL:
  // http://www.chilkatsoft.com/testData/setup.exe
  // This is a program that displays a dialog and exits after pressing a button.
  // You can use this .exe for testing the AutoRun property.

  // You may pass command-line parameters to the auto-run EXE:
  ChilkatZip21.AutoRunParams := '-x -name john -b2';

  // Set a custom icon for your .exe by setting the ExeIconFile to the
  // name of a .ico file on your hard drive.
  ChilkatZip21.ExeIconFile := 'box.ico';

  // If your self-extracting EXE will have an interface, you may customize
  // the title and unzip caption:
  ChilkatZip21.ExeTitle := 'My Application 1.0';
  ChilkatZip21.ExeUnzipCaption := 'Unzipping in progress...';

  // You may encrypt your .exe by setting the Encryption property to 1,2, or 3.
  // 1 = blowfish
  // 2 = twofish
  // 3 = AES (Rijndael)
  ChilkatZip21.Encryption := 3;
  ChilkatZip21.EncryptKeyLength := 128;   // Can also be 192 or 256.
  ChilkatZip21.SetPassword('myPassword');

  // An encrypted EXE must have an interface because it prompts for the password
  // before extracting.

  // Assuming your .exe is unencrypted, it may run interfaceless in one of two ways:
  // 1) Set a pre-defined absolute unzip directory
  // 2) Unzip to a automatically chosen temp directory.
  //
  // To choose a hard-coded unzip directory, set the ExeUnzipDir property:
  ChilkatZip21.ExeUnzipDir := 'c:\myApplication';
  // Don't forget to set ExeNoInterface:
  ChilkatZip21.ExeNoInterface := 1;

  // To unzip to a temp directory, set the AutoTemp property, as well as
  // the ExeNoInterface if you don't want an interface:
  ChilkatZip21.AutoTemp := 1;
  ChilkatZip21.ExeNoInterface := 1;

  // If you set ExeNoInterface = 1, be sure to comment out the lines that
  // turn on encryption.

  // Write the .exe
  success := ChilkatZip21.WriteExe('xyz.exe');
  if (success = 0) then begin
      ChilkatZip21.SaveLastError('zipErrorLog.txt');
      ShowMessage(ChilkatZip21.LastErrorText);
  end;

  ShowMessage('Done!');

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