Copyright: DelphiZip   © . Help file last compiled   Thursday, March 21, 2002 00:46:37.


TZip - Overview
TZip

Units

Classes

Other Types

Routines

Global Variables

Global Constants


TZip - Units
Units

SfxUtils
Zip
ZipDlls


TZip - Classes
Classes

TZip
ZipException


TZip - Types
Types

pExclFileData
pFileInfo
pLocalHeader
pUnzipExFileData
pUnzipFileData
pUnZipParams
pZCallBackStruct
pZipFileData
pZipParams
TAddOption
TAddOptions
TCentralFileHeader
TDataDescriptor
TEndOfCentralHeader
TEOCHInfo
TExclFileData
TExtractOption
TExtractOptions
TFileInfo
TLocalHeader
TProgressEvent
TUnzipExFileData
TUnzipFileData
TUnZipParams
TZCallBackStruct
TZEDBeginFileEvent
TZEDEndBatchEvent
TZipFileData
TZipParams
ZFunctionPtrType


TZip - Routines
Routines

AppendSlash
FindEOCHeaderOffset
GetDiskType
GetTempFilename
GetTempPath
GetVolumeName
JoinFiles
Register
ReplaceExeIcon
StripSfxStub


TZip - Global Variables
Global Variables

GetUnzipDllVersion
GetZipDllVersion
UnzipDllExec
UnzipDllHandle
ZipDllExec
ZipDllHandle


TZip - Global Constants
Global Constants

CENTRAL_HEADERSIG
CRLF
DATA_DESCRIPT_SIG
EOC_HEADERSIG
ERROR_VALUE
LOCAL_HEADERSIG
MAX_PASSWORD_RETRIES
MULTIPLE_DISK_SIG
PASSWORD_MAXLEN
ZIP_VERSION


Legend

 - Marks that the item has an associated example. (this bitmap is a hyperlink.)

 - Marks that the item has documented bugs.


SfxUtils Unit Overview
SfxUtils Unit
Legend

Routines
JoinFiles

Concatenates a list of files into one file.

 ReplaceExeIcon

Replaces an icon image in an executable with an icon image from another file.

 StripSfxStub

Removes the sfx stub from a self-extracting zip executable.


JoinFiles
JoinFiles Function

Concatenates a list of files into one file.

Unit
SfxUtils

Declaration
Function JoinFiles(FileList: TStrings; const TargetFile: string): boolean;

Description
Concatenates files in the order supplied by FileList.

The resulting file is saved to the file named TargetFile.


ReplaceExeIcon
ReplaceExeIcon Procedure

Replaces an icon image in an executable with an icon image from another file.

Unit
SfxUtils

Declaration
Procedure ReplaceExeIcon(const ExeFile, SaveToFile, SrcFile: string; IconNum: cardinal);

Description
Replaces the icon in ExeFile which has the ordinal value IconNum with a matching sized icon in SrcFile. (If IconNum = 0, then the first icon in ExeFile will be replaced, irrespective of its ordinal value.)

SrcFile can be either another exe file or an icon file.

If the function succeeds the new file is saved to SaveToFile overwriting any existing file.

The procedure will fail if no image in SrcFile is the same size as the icon specified in ExeFile.


StripSfxStub
StripSfxStub Function

Removes the sfx stub from a self-extracting zip executable.

Unit
SfxUtils

Declaration
Function StripSfxStub(const SfxExeFile, NewZipFile: string): boolean;

Description
Removes the sfx stub from SfxExeFile.

The resulting file is saved as NewZipFile. If NewZipFile already exists, it will be overwritten.


Zip Unit Overview
Zip Unit
Legend

Classes
TZip
ZipException

Other Types
pFileInfo
TAddOption
TAddOptions
TEOCHInfo
TExtractOption
TExtractOptions
TFileInfo
TProgressEvent
TZEDBeginFileEvent
TZEDEndBatchEvent

Routines
AppendSlash

Append a forward slash to a string (path).

 FindEOCHeaderOffset

Internal function.

 GetDiskType

Wrapper for WinApi function (GetDriveType).

 GetTempFilename
GetTempPath
GetVolumeName

Wrapper for WinApi function (GetVolumeInformation).

 Register

Global Constants
CRLF
ERROR_VALUE
MAX_PASSWORD_RETRIES

Resourcestrings
s_cancel_caption  '&Cancel'

s_cfh_read_error  'Error reading ''CentralFileHeader''!'

s_cfh_write_error  'Error writing ''CentralDirectory''!'

s_comment_read_error  'Unable to read main Zip comment.'

s_comment_write_error  'Unable to write main Zip comment.'

s_crc_error_query_extract  '"%s" may be corrupted (CRC error).'#10'Extract this file anyway? ...'

s_create_multdisk_on_floppies_only  'Multiple disk Zip files can only be created on floppy disks.'

s_eoch_read_error  'Error reading ''EndOfCentralHeader''!'

s_eoch_write_error  'Error writing ''EndOfCentralHeader''.'

s_extract_error_no_folder  'Unable to extract files to:'#10'"%s"'#10'This folder does not exist.'

s_ico_copy_error  'Error copying icon to Exe File.'

s_index_range_error  'Index range error'

s_invalid_dll_version  'Error - invalid version of ZipDll.dll or UnzDll.dll'

s_invalid_password_retry  'Password is invalid, please retry ...'

s_local_data_write_error  'Unable to write local data.'

s_localheader_read_error  'Unable to read LocalHeader'

s_localheader_write_error  'Unable to write LocalHeader.'

s_max_multidisk_at_least_256  'Maximum File Size must be at least 256k.'

s_merge_only_to_fixed_disk  'A multiple disk Zip file can only be merged onto a fixed drive.'

s_min_space_disk1_at_least_256  'Minimum file size on Disk1 must be at least 256k.'

s_multidisk_op_error  'Cannot Add, Delete or Extract from a multiple disk Zip file...'#10+'Merge this Zip file onto the hard disk before retrying.'

s_multidisk_prompt  'Insert [ Disk %d ] of the Zip file into the floppy drive'+#10+'before pressing [ OK ] to continue ...'

s_multidisk_prompt_last  'This is [ Disk %d ] of a multiple disk Zip file.'#10+'Insert the last disk of the Zip file before pressing [ OK ] to continue ...'

s_multidisk_sig_error  'Error reading multiple disk signature'

s_need_multidisk_zip  'This is not a multiple disk Zip file.'

s_new_password_required  'A new password is required for "%s"'

s_newer_file_query_extract  '"%s" is the same age or newer than the zipped file.'#10+'Do you really want to overwrite this file? ...'

s_no_create_vol_label  'Unable to create disk Volume Label'

s_no_icon  'Error - unable to find the specific icon in the Exe File'

s_no_icons  'Error - unable to find any icons in the Exe File'

s_no_matching_ico  'Error - no icon in the Ico File matches the one in the Exe File.'

s_no_password_query_continue  'No password was entered so the file will not be extracted...'#10+'Do you wish to continue extracting other files?'

s_no_select_no_op  'No files have been selected.'

s_no_space_prompt  'There is insufficient room on this floppy disk ...'#10+'Insert another disk into the floppy drive'#10+'before pressing [ OK ] to continue ...'

s_no_zip_no_op  'A Zip file must be openned or created before'#10+'Adding, Deleting or Extracting files.'

s_not_a_zip_file  '"%s"'#10'is not a valid Zip file.'

s_not_an_sfx_file  '"%s"'#10+'is not a valid Self-extracting zip file.'

s_older_file_query_extract  '"%s" is older than the zipped file.'#10'Overwrite this file? ...'

s_password_too_long  'Passwords must be 80 characters or less.'

s_res_not_at_sec_start  'Resources are not at the start of a section!!'

s_sfx_read_error  'Error reading self-extracting zip file.'

s_source_file_cannot_be_on_floppy  'The source file must not be on a floppy disk'

s_unable_to_access_drive  'Unable to access the selected drive!'

s_unable_to_create  'Unable to create '#10'"%s"'

s_unable_to_load  'Unable to load %s'

s_wait_caption  'wait ...'


TZip
 TZip Component
Hierarchy   Properties   Methods   Events

Unit
Zip

Declaration
TZip = class(TComponent)

Description
Non-visual component to support PKZip compatible compression and decompression without requiring 3rd party compression utilities.

This component interfaces with Eric Engler's excellent freeware zip and unzip libraries (DLLs).

Once an archive has been assigned to TZip using the Filename property, the user can Add, Extract and Delete files to and from zip archives.

Multi-disk zip archives are supported by methods to view their contents, to create them, and to convert them to single disk archives.

Comments can be assigned to individual files (see FileComments) within the archive and a general archive comment (see ZipComment) can also be assigned.

Self-extracting executable (Sfx) support is provided independant of this component (see the SfxUtils Unit).

The Password property enables the user to encrypt and decrypt archived files.


Properties for TZip
TZip Properties

Properties   Methods   Events

 In TZip
AddOptions
AddPath
Cancelled
Count
DllPath
ExtractErrorCnt
ExtractOptions
ExtractPath
FileComments
FileInfos
Filename
FileSpecList
OnContentsChanged
Password
SaveTraceLog
SfxSize
ShowProgressDialog
ZipComment


Methods for TZip
TZip Methods

Properties   Methods   Events

 In TZip
 Add
 Cancel
 create
 Delete
 destroy
 Extract
 MergeArchiveTo
 SpanArchiveTo


Events for TZip
TZip Events

Properties   Methods   Events

 In TZip
 OnMergeProgress
 OnSpanProgress
 OnZEDBeginFileEvent
 OnZEDEndBatchEvent
 OnZEDProgressEvent


TZip.AddOptions
AddOptions property

Set of options to modify the Add method's behaviour.

Applies to
TZip

Declaration
Property AddOptions : TAddOptions;

Description

aoFreshen: The Add method will only replace existing zipped files if they are NEWER. Files which are named in FileSpecList but do not exist in the archive will NOT be added.

aoUpdate: The Add method will replace existing zipped files if they are NEWER. Files which are named in FileSpecList but do not exist in the archive will ALSO be added.

If neither aoFreshen nor aoUpdate are in AddOptions then any files named in FileSpecList that already exist in the archive will be overwritten irrespective of their age.

aoRecursive: If folder names are included in the FileSpecList, then all files and folders below that folder will also be added.

aoWithFullPath: Stores the full path (excluding the drive letter) with the filenames

aoFolderEntries: Folder names will also be added as a separate entry in the archive.

aoZipTime: Will set the archives Time Created to that of the newest file in the archive.

aoHiddenFiles: Hidden Files and System Files named in FileSpecList will be not be skipped during the Add procedure.

aoForceDOS: Files will be added using DOS 8.3 shortname format.


TZip.AddPath
AddPath property

Applies to
TZip

Declaration
Property AddPath : string;

Description

Filenames in FileSpecList with relative paths will to be relative to AddPath.

This property is unassigned after each Add procedure.

If AddPath is not assigned then relative paths will be relative to the process's Current Directory.


TZip.Cancelled
Cancelled property

Applies to
TZip

Declaration
Property Cancelled : boolean;


TZip.Count
Count property

Number of entries in the archive.

Applies to
TZip

Declaration
Property Count : integer;

Description

The count of all entries in an opened archive including folder entries if present.


TZip.DllPath
DllPath property

Path to the Zipdll.dll and Unzdll.dll files.

Applies to
TZip

Declaration
Property DllPath : string;

Description

If the Zipdll.dll and Unzdll.dll files are neither in the same folder as the executing application, nor in a folder in the OS's path, then this property must be assigned to enable adding, extracting or deleting of files from archives.


TZip.ExtractErrorCnt
ExtractErrorCnt property

Applies to
TZip

Declaration
Property ExtractErrorCnt : integer;


TZip.ExtractOptions
ExtractOptions property

Set of extraction options.

Applies to
TZip

Declaration
Property ExtractOptions : TExtractOptions;

Description

eoFreshen: Overwrites older existing files with newer files found in the archive. Files which do not exist outside the archive will be skipped.

eoUpdate: Overwrites older existing files with newer files found in the archive. Files which do not exist outside the archive will be extracted too if they are named in FileSpecList.

If neither eoFreshen nor eoUpdate are included in ExtractOptions, then ALL files named in FileSpecList will be extracted. Existing files will be overwritten automatically unless the eoAskOverwrite option is included (see below).

eoAskOverwrite: Ask the user before overwriting an existing file. The user will be informed whether the existing file is older or newer. (This option is ignored if combined with either eoFreshen or eoUpdate.)

eoWithPaths: Extract maintaining the directory structure of the zipped files.

eoTest: Check the files in the archive which are nameed in FileSpecList for CRC errors, without extracting.


TZip.ExtractPath
ExtractPath property

Base path into which files are extracted.

Applies to
TZip

Declaration
Property ExtractPath : string;


TZip.FileComments
FileComments property

Property to read and write individual file comments.

Applies to
TZip

Declaration
Property FileComments[index:integer] : string;


TZip.FileInfos
FileInfos property

ReadOnly property to access the properties of each file in the archive.

Applies to
TZip

Declaration
Property FileInfos[index:integer] : TFileInfo;


TZip.Filename
Filename property

The Zip archive's filename.

Applies to
TZip

Declaration
Property Filename : string;

Description

Assigning a value to Filename will also update the list of contained files. (Information on the contained files is accessed through the FileInfos property.)

An OnContentsChanged event will be triggered once the Filename has been assigned.


TZip.FileSpecList
FileSpecList property

List of filenames to be added, extracted or deleted.

Applies to
TZip

Declaration
Property FileSpecList : TStrings;

Description

Wildcard characters ('?' and '*') can be used instead of literal filenames.


TZip.OnContentsChanged
OnContentsChanged property

Applies to
TZip

Declaration
Property OnContentsChanged : TNotifyEvent;


TZip.Password
Password property

Password to use when adding or extracting encrypted files.

Applies to
TZip

Declaration
Property Password : string;

Description

A password should be assigned prior to an Add or Extract operation if file encryption or decryption is required.

If, during an Extract operation, an encrypted file is encountered, the user will be prompted for a password if the Password property has not been assigned (or is incorrect).


TZip.SaveTraceLog
SaveTraceLog property

Applies to
TZip

Declaration
Property SaveTraceLog : boolean;


TZip.SfxSize
SfxSize property

Size of Sfx stub of opened file.

Applies to
TZip

Declaration
Property SfxSize : integer;

Description

Size of Sfx stub (ReadOnly).


TZip.ShowProgressDialog
ShowProgressDialog property

Show or hide the progress of Add/Extract/Delete zip operations.

Applies to
TZip

Declaration
Property ShowProgressDialog : boolean;

Description

Default to True (Show Progress).


TZip.ZipComment
ZipComment property

General archive comment.

Applies to
TZip

Declaration
Property ZipComment : string;


TZip.Add
Add method

Add a file or files to an opened archive.

Applies to
TZip

Declaration
Function Add: integer;

Description

Files can be added to an opened archive by assigning the files to be added to FileSpecList and setting any AddOptions before calling the Add method.

Add returns the number of files added.

Example:

  zip1.AddOptions := [];
  zip1.FileSpecList := OpenDialog1.files;
  zip1.add;               //executes the add method here.


TZip.AnsiStrToOemStr
AnsiStrToOemStr method

Applies to
TZip

Declaration
Function AnsiStrToOemStr(const s: string): string;


TZip.Cancel
Cancel method

Applies to
TZip

Declaration
Procedure Cancel;


TZip.ClearFileList
ClearFileList method

Applies to
TZip

Declaration
Procedure ClearFileList;


TZip.create
create method

Applies to
TZip

Declaration
Procedure create(aOwner: TComponent);


TZip.Delete
Delete method

Delete a file or files from an opened archive.

Applies to
TZip

Declaration
Function Delete: integer;

Description

Files can be deleted from an opened archive by assigning the files to be deleted to FileSpecList before calling the Delete method.

Delete returns the number of files Deleted.

Example:

  for i := 0 to Listview1.items.count-1 do
    if Listview1.items[i].selected then
      zip1.FileSpecList.add(Listview1.items[i].caption);
  zip1.delete;               //executes the delete method here.


TZip.destroy
destroy method

Applies to
TZip

Declaration
Procedure destroy;


TZip.DoAddDelete
DoAddDelete method

Applies to
TZip

Declaration
Function DoAddDelete(IsAdd: boolean): integer;


TZip.Extract
Extract method

Extract a file or files from an opened archive.

Applies to
TZip

Declaration
Function Extract: integer;

Description

Files can be extracted from an opened archive by assigning the files to be extracted to FileSpecList, assigning the ExtractPath, and setting the ExtractOptions before calling the Extract method.

Extract returns the number of files Extracted.

Example:

  for i := 0 to Listview1.items.count-1 do
    if Listview1.items[i].selected then
      zip1.FileSpecList.add(Listview1.items[i].caption);
  zip1.ExtractPath := folder;
  //overwrite existing files if they're older...
  zip1.ExtractOptions := [eoUpdate];
  //execute the extract method ...
  zip1.extract;


TZip.GetCount
GetCount method

Applies to
TZip

Declaration
Function GetCount: integer;


TZip.GetFileComment
GetFileComment method

Applies to
TZip

Declaration
Function GetFileComment(index: integer): string;


TZip.GetFileInfo
GetFileInfo method

Applies to
TZip

Declaration
Function GetFileInfo(index: integer): TFileInfo;


TZip.GetZipComment
GetZipComment method

Applies to
TZip

Declaration
Function GetZipComment: string;


TZip.LoadFileList
LoadFileList method

Applies to
TZip

Declaration
Procedure LoadFileList;


TZip.LoadUnZipDll
LoadUnZipDll method

Applies to
TZip

Declaration
Function LoadUnZipDll: boolean;


TZip.LoadZipDll
LoadZipDll method

Applies to
TZip

Declaration
Function LoadZipDll: boolean;


TZip.MergeArchiveTo
MergeArchiveTo method

Applies to
TZip

Declaration
Function MergeArchiveTo(const Target: string): boolean;


TZip.OemStrToAnsiStr
OemStrToAnsiStr method

Applies to
TZip

Declaration
Function OemStrToAnsiStr(const s: string): string;


TZip.SetFileComment
SetFileComment method

Applies to
TZip

Declaration
Procedure SetFileComment(index: integer; comment: string);


TZip.SetFilename
SetFilename method

Applies to
TZip

Declaration
Procedure SetFilename(const filename: string);


TZip.SetFileSpecList
SetFileSpecList method

Applies to
TZip

Declaration
Procedure SetFileSpecList(strings: TStrings);


TZip.SetPassword
SetPassword method

Applies to
TZip

Declaration
Procedure SetPassword(const password: string);


TZip.SetZipComment
SetZipComment method

Applies to
TZip

Declaration
Procedure SetZipComment(comment: string);


TZip.SpanArchiveTo
SpanArchiveTo method

Applies to
TZip

Declaration
Function SpanArchiveTo(const Target: string; MaxBytesPerDisk, BytesToReserveDisk1: integer): boolean;


TZip.UnLoadDlls
UnLoadDlls method

Applies to
TZip

Declaration
Procedure UnLoadDlls;


TZip.OnMergeProgress
OnMergeProgress Event

Progress event triggered when merging a multi-disk archive into a single archive.

Applies to
TZip

Declaration
TProgressEvent = Procedure(Sender: TObject; const Filename: string;    BytesDone, TotalBytes: longint) of object;

Description

Progress event triggered after every 32K of the file is copied.


TZip.OnSpanProgress
OnSpanProgress Event

Progress event triggered when spanning a single archive into a multi-disk archive.

Applies to
TZip

Declaration
TProgressEvent = Procedure(Sender: TObject; const Filename: string;    BytesDone, TotalBytes: longint) of object;

Description

Progress event triggered after every 32K of the file is copied.


TZip.OnZEDBeginFileEvent
OnZEDBeginFileEvent Event

Event triggered just before each file is added, deleted or extracted.

Applies to
TZip

Declaration
TZEDBeginFileEvent = Procedure(Sender: TObject; const Filename: string;    FileSize, BatchCount, TotalBytesInBatch: longint) of object;


TZip.OnZEDEndBatchEvent
OnZEDEndBatchEvent Event

Event triggered after all files have been added, deleted or extracted.

Applies to
TZip

Declaration
TZEDEndBatchEvent = Procedure(Sender: TObject;    SkippedCount, BatchCount, TotalBytesInBatch: longint) of object;


TZip.OnZEDProgressEvent
OnZEDProgressEvent Event

Progress event triggered during an add or extract operation.

Applies to
TZip

Declaration
TProgressEvent = Procedure(Sender: TObject; const Filename: string;    BytesDone, TotalBytes: longint) of object;

Description

Progress event triggered after every 32K of the file is copied.


ZipException
ZipException Object
Hierarchy

Unit
Zip

Declaration
ZipException = class(Exception)


AppendSlash
AppendSlash Function

Append a forward slash to a string (path).

Unit
Zip

Declaration
Function AppendSlash(const str: string): string;


FindEOCHeaderOffset
FindEOCHeaderOffset Function

Internal function.

Unit
Zip

Declaration
Function FindEOCHeaderOffset(stream: TStream): longint;


GetDiskType
GetDiskType Function

Wrapper for WinApi function (GetDriveType).

Unit
Zip

Declaration
Function GetDiskType(const filename: string): integer;


GetTempFilename
GetTempFilename Function

Unit
Zip

Declaration
Function GetTempFilename: string;


GetTempPath
GetTempPath Function

Unit
Zip

Declaration
Function GetTempPath: string;


GetVolumeName
GetVolumeName Function

Wrapper for WinApi function (GetVolumeInformation).

Unit
Zip

Declaration
Function GetVolumeName(DrivePath: string; out VolumeName: string): boolean;


Register
Register Procedure

Unit
Zip

Declaration
Procedure Register;


pFileInfo
pFileInfo type

Unit
Zip

Declaration
pFileInfo = ^TFileInfo;


TAddOption
TAddOption type

Unit
Zip

Declaration
TAddOption = (aoFreshen, aoUpdate, aoRecursive, aoWithFullPath,
    aoFolderEntries, aoZipTime, aoHiddenFiles, aoForceDOS);


TAddOptions
TAddOptions type

Unit
Zip

Declaration
TAddOptions = set of TAddOption;


TEOCHInfo
TEOCHInfo type

Unit
Zip

Declaration
TEOCHInfo = packed record
    eoch        : TEndOfCentralHeader;
    ZipComment  : string;     //ANSI format
    EocOffset   : integer;
  end;


TExtractOption
TExtractOption type

Unit
Zip

Declaration
TExtractOption = (eoUpdate, eoFreshen, eoTest, eoAskOverwrite, eoWithPaths);


TExtractOptions
TExtractOptions type

Unit
Zip

Declaration
TExtractOptions = set of TExtractOption;


TFileInfo
TFileInfo type

Unit
Zip

Declaration
TFileInfo = packed record
    cfh           : TCentralFileHeader;
    PasswordUsed  : Boolean;
    Filename      : string;   //ANSI format
    ExtraField    : string;
    FileComment   : string;   //ANSI format
    Reserved1     : Cardinal; //2 fields used internally by TZip when
    Reserved2     : Cardinal; //creating spanned archives.
  end;


TProgressEvent
TProgressEvent type

Unit
Zip

Declaration
TProgressEvent = procedure(Sender: TObject; const Filename: string;
    BytesDone, TotalBytes: longint) of object;


TZEDBeginFileEvent
TZEDBeginFileEvent type

Unit
Zip

Declaration
TZEDBeginFileEvent = procedure(Sender: TObject; const Filename: string;
    FileSize, BatchCount, TotalBytesInBatch: longint) of object;


TZEDEndBatchEvent
TZEDEndBatchEvent type

Unit
Zip

Declaration
TZEDEndBatchEvent = procedure(Sender: TObject;
    SkippedCount, BatchCount, TotalBytesInBatch: longint) of object;


CRLF constant
CRLF global constant

Unit
Zip

Declaration
CRLF = #13#10;


ERROR_VALUE constant
ERROR_VALUE global constant

Unit
Zip

Declaration
ERROR_VALUE = -1;


MAX_PASSWORD_RETRIES constant
MAX_PASSWORD_RETRIES global constant

Unit
Zip

Declaration
MAX_PASSWORD_RETRIES = 3;


Hierarchy

TComponent
     |
TZip

Subclasses
None


Hierarchy

Exception
     |
ZipException

Subclasses
None


ZipDlls Unit Overview
ZipDlls Unit
Legend

Other Types
pExclFileData
pLocalHeader
pUnzipExFileData
pUnzipFileData
pUnZipParams
pZCallBackStruct
pZipFileData
pZipParams
TCentralFileHeader
TDataDescriptor
TEndOfCentralHeader
TExclFileData
TLocalHeader
TUnzipExFileData
TUnzipFileData
TUnZipParams
TZCallBackStruct
TZipFileData
TZipParams
ZFunctionPtrType

Global Variables
GetUnzipDllVersion
GetZipDllVersion
UnzipDllExec
UnzipDllHandle
ZipDllExec
ZipDllHandle

Global Constants
CENTRAL_HEADERSIG
DATA_DESCRIPT_SIG
EOC_HEADERSIG
LOCAL_HEADERSIG
MULTIPLE_DISK_SIG
PASSWORD_MAXLEN
ZIP_VERSION


pExclFileData
pExclFileData type

Unit
ZipDlls

Declaration
pExclFileData = ^TExclFileData;


pLocalHeader
pLocalHeader type

Unit
ZipDlls

Declaration
pLocalHeader = ^TLocalHeader;


pUnzipExFileData
pUnzipExFileData type

Unit
ZipDlls

Declaration
pUnzipExFileData = ^TUnzipExFileData;


pUnzipFileData
pUnzipFileData type

Unit
ZipDlls

Declaration
pUnzipFileData = ^TUnzipFileData;


pUnZipParams
pUnZipParams type

Unit
ZipDlls

Declaration
pUnZipParams = ^TUnZipParams;


pZCallBackStruct
pZCallBackStruct type

Unit
ZipDlls

Declaration
pZCallBackStruct = ^TZCallBackStruct;


pZipFileData
pZipFileData type

Unit
ZipDlls

Declaration
pZipFileData = ^TZipFileData;


pZipParams
pZipParams type

Unit
ZipDlls

Declaration
pZipParams = ^TZipParams;


TCentralFileHeader
TCentralFileHeader type

Unit
ZipDlls

Declaration
TCentralFileHeader = packed record  // fixed part size = 46 bytes
    HeaderSig          : Cardinal; // $02014b50 { 'PK'#1#2 } (4)
    MadeByVersion      : Byte;    //(1)
    HostVersionNo      : Byte;    //(1)
    Version            : Word;    //version needed to extract(2)
    Flag               : Word;    //(2)
    CompressionMethod  : Word;    //(2)
    FileDate           : Integer; //convert with FileDateToDateTime (4)
    CRC32              : Integer; //(4)
    CompressedSize     : Integer; //(4)
    UncompressedSize   : Integer; //(4)
    FileNameLength     : Word;    //(2)
    ExtraFieldLength   : Word;    //(2)
    FileCommentLen     : Word;    //(2)
    StartOnDisk        : Word;    //disk # on which file starts (2)
    IntFileAttrib      : Word;    //internal file attr. ie: Text/Binary (2)
    ExtFileAttrib      : Cardinal;//external file attr. (4)
    RelOffLocalHdr     : integer; //relative offset of LocalHeader (4)
  end;


TDataDescriptor
TDataDescriptor type

Unit
ZipDlls

Declaration
TDataDescriptor = packed record  //Exists only if bit 3 of LocalHeader.Flag is set.
    DescriptorSig      : Cardinal; //field not defined in PKWare's docs but used by WinZip
    CRC32              : Cardinal;
    ComprSize          : integer;
    UnComprSize        : integer;
  end;


TEndOfCentralHeader
TEndOfCentralHeader type

Unit
ZipDlls

Declaration
TEndOfCentralHeader = packed record  //Fixed part size = 22 bytes
    HeaderSig          : Cardinal; //$06054B50 (4)
    ThisDiskNo         : Word;     //This disk's number (zero based) (2)
    CentralDiskNo      : Word;     //Disk number on which central dir starts (2)
    ThisDiskEntries    : Word;     //Number of central dir entries on this disk (2)
    TotalEntries       : Word;     //Total entries in central dir (2)
    CentralSize        : integer;  //Size of central directory (4)
    CentralOffset      : integer;  //offset of central dir on CentralDiskNo (4)
    ZipCommentLen      : Word;     //(2)
  end;


TExclFileData
TExclFileData type

Unit
ZipDlls

Declaration
TExclFileData = packed record
   fFileSpec:        pChar;
  end;


TLocalHeader
TLocalHeader type

Unit
ZipDlls

Declaration
TLocalHeader = packed record
    HeaderSig          : Cardinal; // $04034b50 (4)
    VersionNeed        : Word;
    Flag               : Word;
    ComprMethod        : Word;
    FileTime           : Word;
    FileDate           : Word;
    CRC32              : Cardinal;
    ComprSize          : integer;
    UnComprSize        : integer;
    FileNameLen        : Word;
    ExtraLen           : Word;
  end;


TUnzipExFileData
TUnzipExFileData type

Unit
ZipDlls

Declaration
TUnzipExFileData = packed record
    fFileSpec:       PChar;
    fNotUsed:        Array[0..2] of Cardinal;
  end;


TUnzipFileData
TUnzipFileData type

Unit
ZipDlls

Declaration
TUnzipFileData = packed record
    fFileSpec:       PChar;
    fFileAltName:    PChar;
    fPassword:       PChar;
    fNotUsed:        Array[0..14] of Cardinal;
  end;


TUnZipParams
TUnZipParams type

Unit
ZipDlls

Declaration
TUnZipParams = packed record
    Handle:             THandle;
    Caller:             Pointer;  //used as pointer to self in callback function
    Version:            LongInt;  //expected dll version
    ZCallbackFunc:      ZFunctionPtrType;
    TraceEnabled:      LongBool;
    PromptToOverwrite: LongBool;
    ZipPassword:       PChar;
    Test:              LongBool;  //test that files extract then trash extracted files
    Comments:          LongBool;
    Convert:           LongBool;  //if true, do ASCII/EBCDIC or EOL translation
    Quiet:             LongBool;
    VerboseEnabled:    LongBool;
    Update:            LongBool;  //"update" (extract only newer files & brand new files)
    Freshen:           LongBool;  //"freshen" (extract only newer files that already exist)
    Directories:       LongBool;  //if true, recreate dir structure
    Overwrite:         LongBool;  //if true, overwrite existing (no asking)
    FileDataCount:     LongInt;   //number of files to extract
    ZipFilename:       PChar;     //pointer to archive name

    {Pointer to an Array of UnzipFileData records}
    UnzipFileData:     pUnzipFileData;
    {Pointer to an Array of ExUnzipFileData records}
    UnzipExFileData:   pUnzipExFileData;
    UseOutStream:      LongBool;  //Use Memory stream as output. (v1.60)
    OutStream:         Pointer;   //Pointer to the start of streaam data. (v1.60)
    OutStreamSize:     LongInt;   //Size of the output data. (v1.60)
    UseInStream:       LongBool;  //Use memory stream as input. (v1.60)
    InStream:          Pointer;   //Pointer to the start of the input stream data. (v1.60)
    InStreamSize:      LongInt;   //Size of the input data. (v1.60)
    PwdReqCount:       Cardinal;  //No. of times a password will be asked for per file (v1.60)
    ExtractRoot:       PChar;     //NEW VER160p: pointer to Extract Base Dir.
    NotUsed:           Array[0..7] of Cardinal;
    Seven:             LongInt;   //$0007
  end;


TZCallBackStruct
TZCallBackStruct type

Unit
ZipDlls

Declaration
TZCallBackStruct = packed record
     Handle: THandle;
     Caller: Pointer;          //pointer to "self"
     Version: LongInt;         //expected dll version
     IsOperationZip: LongBool; //true=zip, false=unzip
     ActionCode: LongInt;
     ErrorCode: LongInt;
     Size: LongInt;
     Msg: Array[0..511] of Char;
  end;


TZipFileData
TZipFileData type

Unit
ZipDlls

Declaration
TZipFileData = packed record
    FileSpec:       PChar;
    FileComment:    PChar;
    FileAltName:    PChar;
    Password:       PChar;
    Encrypt:        LongBool;
    Recurse:        Word;
    NoRecurseFile:  Word;
    DateUsed:       LongBool;
    Date:           Array[0..7] of Char;
    AddRoot:        PChar;
    NotUsed:        Array[0..15] of Cardinal;
  end;


TZipParams
TZipParams type

Unit
ZipDlls

Declaration
TZipParams = packed record
    Handle:          THandle;
    Caller:          Pointer;  //used as pointer to self in callback function
    Version:         LongInt;  //expected dll version
    ZCallbackFunc:   ZFunctionPtrType;
    TraceEnabled:   LongBool;
    ZipPassword:    PChar;    //pointer to password
    Suffix:         LongBool; //unused
    Encrypt:        LongBool; //encrypt new files
    SystemFiles:    LongBool; //include system & hidden files
    Volume:         LongBool; //save volume label
    Extra:          LongBool; //save file attributes
    NoDirEntries:   LongBool; //don't save directory names (see also fJunkDir)
    UseDate:        LongBool; //use date array to replace updated files
    VerboseEnabled: LongBool; //feedback extra info from dll with messages
    Quiet:          LongBool; //dll shows no messages, ie: handle messages via callbacks
    Level:          LongInt;  //compression level: 0=nil, 9=max
    ComprSpecial:   LongBool; //try and compress compressed file types eg: gif, zip
    CRLF_LF:        LongBool; //translate textfile eol's
    JunkDir:        LongBool; //ignore saving directories
    Recurse:        WordBool; //recurse subdirectories
    NoRecurseFiles: Word;
    Grow:           LongBool; //allow append of files
    ForceDOS:       LongBool; //for 8.3 filenames -> PKUNZIP v2.04g compatibility
    Move:           LongBool; //delete uncompressed originals after added to zip.
    DeleteEntries:  LongBool; //delete specified files from archive
    Update:         LongBool; //add - update
    Freshen:        LongBool; //add - freshen
    JunkSFX:        LongBool; //strip sfx prefix for self-extracting archives
    LatestTime:     LongBool; //set zip archive to datetime of latest zipped file
    Date:           Array[0..7] of Char; //if fDate=true then add newer than: MMDDYY**
    FileDataCount:  LongInt;  //number of Files (or FileSpecs) to add/delete
    ZipFilename:    PChar;    //pointer to archive name

    TempPath:       PChar;    //pointer to temp path
    FileComment:    PChar;    //pointer to comments
    ArchivedOnly:   WordBool; //only zip when archive bit set (v1.60)
    ResetArchive:   WordBool; //reset the archive bit after a successfull zip (v1.60)
    FileData:       pZipFileData; //pointer to array of FileData
    ForceWin:       LongBool;
    ExclDataCount:  LongInt;  //number of excluded FileSpecs
    ExclFileData:   pExclFileData; // pointer to array of FileSpecs to exclude from zipping.

    UseOutStream:     LongBool;   // NEW component v160M, dll v1.6015 Use memory stream as output.
    OutStream:        Pointer;    // NEW component v160M, dll v1.6015 Pointer to the start of the output stream data.
    OutStreamSize:    LongWord;   // NEW component v160M, dll v1.6015 Size of the Output data.
    UseInStream:      LongBool;   // NEW component v160M, dll v1.6015 Use memory stream as input.
    InStream:         Pointer;    // NEW component v160M, dll v1.6015 Pointer to the start of the input stream data.
    InStreamSize:     LongWord;   // NEW component v160M, dll v1.6015 Size of the input data.
    StrFileAttr:      DWORD;      // NEW component v160M, dll v1.6015 File attributes of the file stream.
    StrFileDate:      DWORD;      // NEW component v160M, dll v1.6015 File date/time to set for the streamed file.
    HowToMove:        LongBool;
    WantedCodePage:   SmallInt;
    NotUsed0:         SmallInt;
    NotUsed:        Array[0..3] of Cardinal;
    Seven:          Integer;  //$0007
  end;


ZFunctionPtrType
ZFunctionPtrType type

Unit
ZipDlls

Declaration
ZFunctionPtrType = function(ZCallbackRec: PZCallBackStruct): LongBool; stdcall;


GetUnzipDllVersion variable
GetUnzipDllVersion global variable

Unit
ZipDlls

Declaration
GetUnzipDllVersion : function: DWord; stdcall;


GetZipDllVersion variable
GetZipDllVersion global variable

Unit
ZipDlls

Declaration
GetZipDllVersion : function : DWord; stdcall;


UnzipDllExec variable
UnzipDllExec global variable

Unit
ZipDlls

Declaration
UnzipDllExec : function( UnZipRec: pUnZipParams ): DWord; stdcall;


UnzipDllHandle variable
UnzipDllHandle global variable

Unit
ZipDlls

Declaration
UnzipDllHandle : THandle;


ZipDllExec variable
ZipDllExec global variable

Unit
ZipDlls

Declaration
ZipDllExec : function( ZipRec: pZipParams ): DWord; stdcall;


ZipDllHandle variable
ZipDllHandle global variable

Unit
ZipDlls

Declaration
ZipDllHandle : THandle;


CENTRAL_HEADERSIG constant
CENTRAL_HEADERSIG global constant

Unit
ZipDlls

Declaration
CENTRAL_HEADERSIG = $02014b50;


DATA_DESCRIPT_SIG constant
DATA_DESCRIPT_SIG global constant

Unit
ZipDlls

Declaration
DATA_DESCRIPT_SIG = MULTIPLE_DISK_SIG;


EOC_HEADERSIG constant
EOC_HEADERSIG global constant

Unit
ZipDlls

Declaration
EOC_HEADERSIG = $06054b50;


LOCAL_HEADERSIG constant
LOCAL_HEADERSIG global constant

Unit
ZipDlls

Declaration
LOCAL_HEADERSIG = $04034b50;


MULTIPLE_DISK_SIG constant
MULTIPLE_DISK_SIG global constant

Unit
ZipDlls

Declaration
MULTIPLE_DISK_SIG = $08074b50;


PASSWORD_MAXLEN constant
PASSWORD_MAXLEN global constant

Unit
ZipDlls

Declaration
PASSWORD_MAXLEN = 80;


ZIP_VERSION constant
ZIP_VERSION global constant

Unit
ZipDlls

Declaration
ZIP_VERSION = 160;


Welcome to TZip

The TZip component was created as an alternative to DelphiZip's TZipMstr component.

The core functionality of TZipMstr has been duplicated by TZip but size has been reduced. Backward compatability code has been removed and non-core zip functionality (SFX support in particular) has been placed in a separate unit. Some functionality in TZipMstr (which I suspect is rarely used) is not currently supported by TZip. An alternative SFX exe stub is also included (with source).

TZip was originally written for my private use. When Eric Engler (the author of DelphiZip) mentioned in a delphi newsgroup his plan to write a simplified version of TZipMstr, I offered him TZip. It was not quite what Eric was expecting but he was eager to include it on the DelphiZip website as an alternative means of accessing his DelphiZip dlls.

The TZip component is declared and implemented in the Zip Unit. Record definitions and functions necessary for interfacing with Zipdll.dll and Unzdll.dll can be found in the ZipDlls Unit together with zip archive record definitions. The SfxUtils Unit contains a couple of functions useful for adding/removing self-extracting executable stubs to/from zip archives, together with a function for replacing icons in executables.

Angus Johnson
ajohnson@rpi.net.au

21 March 2002.

Thanks to Time2Help (http://www.time2help.com) for their help compiler which has made the making of this file a relatively painless task.


Author, Copyright, Licensing and Disclaimer

Principal Author:

Angus Johnson
ajohnson@rpi.net.au

Copyright:

Copyright © 2001-2002.

With the exception of the Zipdll and Unzdll libraries (dlls) and any source code directly attributed to and copyrighted by other authors, all source and binary code in this archive is copyrighted by the principal author and will be referred to as "The Code" herein.

Licence to use, terms and conditions:

"The Code" is released as freeware provided that you agree to the following terms and conditions:

 1.	the copyright notices displayed in source code are retained;

 2.	if modifications to the source code are made, then a statement to that effect should be included immediately below the original copyright notice together with the modifier's name.

Note:

•	A developer is not required to display an acknowledgement of the use of "The Code" when it is compiled into binary format.

•	The terms and conditions of using "The Code" are different to that of the Zipdll and Unzdll libraries copyrighted by Eric Engler.

Disclaimer:

A user of this software acknowledges that he or she is receiving this software on an "as is" basis and the user is not relying on the accuracy or functionality of the software for any purpose. The user further acknowledges that any use of this software will be at the user's own risk and the copyright owner accepts no responsibility whatsoever arising from the use or application of the software.