📄 zipunzip.pas
字号:
One good side-effect of using the central directory is speed. We
can now read a zip file's contents very quickly.
This release also lets you read the main zip file comments, and the
comments for individual file entries. However, these comments can
only be read - you can not create zip comments with v1.50.
These new read-only runtime properties tell you about the zip file.
These are valid after a zip file's contents have been read (which
happens when you assign something to ZipFilename).
ZipFileSize: size of entire Zip file (if spanning, then size of
the last chunk)
SFXOffset: size of the Self-extracting code at the beginning (only
used for non-spanning archives)
ZipSOC: Start-Of-Central-Dir location
ZipEOC: End-Of-Central-Dir location
ZipComment: The text comment for this zip file. Up to 64K in size.
If individual files have comments, you can read them from the ZipDirEntry
record when you examine the zip directory.
Two new action codes have been added to the Progress Event. use the
values you get from these callbacks instead of the GetTotalFileSize
method introduced in v1.45. These values are calculated in the DLLs,
and they should be more accurate than the GetTotalFileSize method.
TotalFiles2Process - the "FileSize" arg tells you how many files will be
processed by this operation
TotalSize2Process - the "FileSize" arg tells you the total size of all
files to be processed by this operation
New SFX changes for this release:
- copyright info is now hidden under the "About" button
- the "Shell Browse for Folder" API is used to select a directory
- a new SFXOption is SFXCheckSize. By default this is on. When on,
the SFX code will do a quick Self-test before expanding the files.
This detects the most common problem - where your .exe file has been
cut short by an aborted download.
NOTE: The SFX module has to be limited in size, and so we did NOT
add support for disk-spanning to it. You can, however, write your
own setup program to re-assemble the pieces. I recommend putting
the files for disk1 into an SFX .EXE, and have it run your setup
program after expanding those files on the user's hard drive. Your
setup program can then read the remaining disks.
Also new in v1.50: we convert forward slashes in filenames to backslashes.
We used to show you forward slashes because that's what Phil Katz (the
inventor of pkzip) did, but we now show you the right slashes! Sorry
Phil!
There is a new requirement for programs that you write. We have
put most of our error messages put into a resource file. You
need to add the desired resource file to your project file.
Simply add a line like this to your project file:
{$R ZipMsgUS.res}
You can see how this was done by checking Demo1's .DPR file.
These are the languages we support at this time:
ZipMsgBR.res - Brazilian (Portuguese)
ZipMsgCZ.res - Czech
ZipMsgNL.res - Dutch
ZipMsgFR.res - French
ZipMsgUS.res - English / US
ZipMsgDE.res - German
ZipMsgGR.res - Greek
ZipMsgIT.res - Italian
ZipMsgPL.res - Polish
ZipMsgYU.res - Serbian (Yugoslavia)
ZipMsgSP.res - Spanish
ZipMsgTW.res - Taiwanese/Traditional Chinese
ZipMsgRU.res - Russian
ZipMsgCN.res - Chinese
ZipMsgHU.res - Hungarian
ZipMsgSW.res - Swedish
ZipMsgMY.res - Malaysia
If you would like to port these error messages to another
language, please e-mail me right away!
----------------------------------------------------------------------
Quick summary of changes in version 1.45:
bug fixes:
Correct the bug in DateTime setting of CopyFile method
Correct misc bugs in the SFX code
new BCB features:
Update BCB support to work with BCB v3
new Delphi features:
Add new "Unattended" property - all errors go to OnMessage error handler
if this property is set True
A new Error code list is being distributed with this release (helpful
if you want to use the Unattended property)
Add new ability to create an .EXE file directly
Add a new demo program (demo5) to demo creation of an .EXE file
Add function "GetTotalFileSize" to let you determine how big
all the files are before starting a zip operation
Update Demo1 to show 2 progress bars in Add: one "overall progress"
and one "per file progress"
----------------------------------------------------------------------
Quick summary of changes in version 1.40:
bug fixes:
Correct filenames are now given in the "skipping encrypted file..."
error messages. Thanks to: Markus Stephany, mirbir.st@saargate.de
The SFX module now extracts more than 1 passworded file in an
archive. Thanks to: Markus Stephany, mirbir.st@saargate.de
Correct progress events now generated for extraction of
uncompressed files. Thanks to: Esa Raita, eza@netlife.fi
DLLDirectory property - allows manual specification of the dir
used to hold ZIPDLL.DLL and UNZDLL.DLL. Should NOT end
in a slash. This is an optional property. if used, it overrides
the Windows search path for DLLs. If you specify a dirname
here, but the DLLs are not actually in that dir, then the
std Windows search path will be consulted.
The idea for this came from Thomas Hensle, thensle@t-online.de.
In case SFXPath isn't set, DLLDirectory will also be consulted
when trying to locate ZIPSFX.BIN. Here's the order that will
be used to locate ZIPSFX.BIN:
1) location given by the SFXPath property
2) the current directory
3) the application directory (location of current .EXE file)
4) the Windows System directory (where DLLs go)}
5) the Windows directory (where DLLs go)
6) location given by the DLLDirectory property
These are the advanced options for creating more powerful Self-Extracting
archives. By using these options, you can turn the new .EXE archive into
a small Self-contained setup program!
The following three boolean options are set members of SFXOptions:
SFXAskCmdLine boolean (only matters if a cmd line is present)
If yes, allows user to de-select the command line checkbox.
Once deselected, the command line will not be run.
NOTE: The checkbox doesn't appear unless there is a command line
specified.
SFXAskFiles boolean (if yes, lets user modify list of files
to be extracted)
SFXHideOverWriteBox boolean (if yes, does NOT show the user the
dialog box that lets him choose the overwrite action at runtime for
files that already exist)
SFXOverWriteMode enum dflt=ovrConfirm (others: ovrAlways, ovrNever)
This is the dflt overwrite option (if SFXHideOverWriteBox is true, then
this option will be used during extraction)
SFXCaption String dflt='Self-extracting Archive'
Caption of the SFX dialog box at runtime.
SFXDefaultDir String dflt=''
Default target dir for extraction. Can be changed at runtime.
If you don't specify this, the user's current directory will
be the default.
SFXCommandLine String dflt=''
This command line will be executed immediately after extracting the
files. Typically used to view the readme file, but can do anything.
There is a predefined symbol that can be used in the command line
to tell you which target directory was actually used.
Special symbols: | is the command/arg separater
>< is the actual extraction dir selected by user
Example:
notepad.exe|><readme.txt
Run notepad to show "readme.txt" in the actual extraction dir.
------------------------------------------------------------------------
TZipMaster is a non-visual VCL wrapper for my freeware ZIP and
UNZIP DLLs. At run time, the DLL's: ZIPDLL.DLL and UNZDLL.DLL must
be present on the hard disk - in C:\WINDOWS\SYSTEM or else in your
application directory, or a directory in the PATH.
These DLLs are based on the InfoZip Official Freeware Zip/Unzip
source code, but they are NOT equivalent to InfoZip's DLLs.
I have modified the InfoZip source code to enhance their
ease-of-use, power, and flexibility for use with Delphi and
C++ Builder. Please do NOT contact InfoZip for issues
regarding this port.
To obtain the official InfoZip source code, consult their
Web site:
http://www.cdrom.com/pub/infozip/
The six main methods that can be invoked are:
Add - add one or more files to a ZIP archive
Delete - delete one or more files from ZIP archive
Extract - expand one or more files from a ZIP archive
List - transfer "table of contents" of ZIP archive
to a StringList
CopyFile - copies a file
GetAddPassword - prompt user for a password - does verify
GetExtrPassword - prompt user for a password - does NOT verify
NOTE: "Test" is a sub-option of Extract
All of the methods above will work on regular .ZIP files, and
on Self-extracting ZIP archives having a file extension of .EXE.
Various properties exist to control the actions of the methods.
Filespecs are specified in the FSpecArgs TStringList property, so you
can easily combine many different filespecs into one Add, Delete, or
Extract operation. For example:
1. Add entries directly to the FSpecArgs property:
ZipMaster1.FSpecArgs.Add( 'C:\AUTOEXEC.BAT' );
ZipMaster1.FSpecArgs.Add( 'C:\DELPHI\BIN\DELPHI.EXE' );
ZipMaster1.FSpecArgs.Add( 'C:\WINDOWS\*.INI' );
ZipMaster1.FSpecArgs.Add( 'SYSTEM\*.DLL' );
2. Take the filespecs from a StringList, just assign them all over
to ZipMaster1.
ZipMaster1.FSpecArgs.Assign(StringList1);
3. Take the filespecs from a ListBox, just assign them all over
to ZipMaster1.
ZipMaster1.FSpecArgs.Assign(ListBox1.Items);
You can specify either the MS-DOS backslash path symbol, or the one
normally used by PKZIP (the Unix path separator: /). They are treated
exactly the same.
All of your FSpecArgs accept MS-DOS wildcards.
Add, Delete, and Extract are the only methods that use FSpecArgs.
The List method doesn't - it just lists all files.
Following is a list of all TZipMaster properties, events and methods:
Properties
==========
Verbose Boolean If True, ask for the maximum amount of "possibly
important" information from the DLLs. The
informational messages are delivered to your
program via the OnMessage event, and the ErrCode
and Message properties. This is primarily used
to determine how much info you want to show your
"end-users" - developers can use the Trace
property to get additional infomation.
Trace Boolean Similar to Verbose, except that this one is
aimed at developers. It lets you trace the
execution of the C code in the DLLs. Helps
you locate possible bugs in the DLLs, and
helps you understand why something is happening
a certain way.
ErrCode Integer Holds a copy of the last error code sent to
your program by from DLL. 0=no error.
See the OnMessage event. Most messages from
the DLLs will have an ErrCode of 0.
Message String Holds a copy of the last message sent to your
program by the DLL. See the OnMessage event.
ZipContents TList Read-only TList that contains the directory
of the archive specified in the ZipFilename
property. Every entry in the list points to
a ZipDirEntry record. This is automatically
filled with data whenever an assignment is
made to ZipFilename, and can be manually
filled by calling the List method.
For your convenience, this VCL hides the
TList memory allocation issues from you.
Automatic updates to this list occur
whenever this VCL changes the ZIP file.
Event OnDirUpdate is triggered for you
each time this list is updated - that is
your queue to refresh your directory display.
---------------------------------------------------------------------
Each entry in the ZipContents TList is a ZipDirEntry record:
ZipDirEntry = packed Record
MadeByVersion : Byte;
HostVersionNo : Byte;
Version : WORD;
Flag : WORD;
CompressionMethod : WORD;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -