📄 zipunzip.pas
字号:
DateTime : Integer; { Time: Word; Date: Word; }
CRC32 : Integer;
CompressedSize : Integer;
UncompressedSize : Integer;
FileNameLength : WORD;
ExtraFieldLength : WORD;
FileCommentLen : Word;
StartOnDisk : Word;
IntFileAttrib : Word;
ExtFileAttrib : LongWord;
RelOffLocalHdr : LongWord;
FileName : String; // variable size
FileComment : String; // variable size
end;
To get compression ratio:
(code from Almer Tigelaar)
var
ratio: Integer;
begin
with ZipDirEntry1 do
ratio:=Round((1-(CompressedSize/UnCompressedSize))*100);
---------------------------------------------------------------------
Cancel Boolean If you set this to True, it will abort any
Add or Extract processing now underway. There
may be a slight delay before the abort will
take place. Note that a ZIP file can be
corrupted if an Add operation is aborted.
ZipBusy Boolean If True, a ZIP operation is underway - you
must delay your next Add/Delete operation
until this is False. You won't need to be
concerned about this in most applications.
This can be used to syncronize Zip operations
in a multi-threaded program.
UnzBusy Boolean If True, an UNZIP operation is underway -
you must delay your next Extract operation
until this is False. You won't need to be
concerned about this in most applications.
This can be used to syncronize UnZip
operations in a multi-threaded program.
AddCompLevel Integer Compression Level. Range 0 - 9, where 9
is the tightest compression. 2 or 3 is a
good trade-off if you need more speed. Level 0
will just store files without compression.
I recommend leaving this at 9 in most cases.
AddOptions Set This property is used to modify the default
action of the Add method. This is a SET of
options. If you want an option to be True,
you need to add it to the set. This is
consistant with the way Delphi deals with
"options" properties in general.
AddDirNames If True, saves the pathname with each fname.
Drive IDs are never stored in ZIP file
directories. NOTE: the root directory name is
never stored in a pathname; in other words,
the first character of a pathname stored in
the zip file's directory will never be a slash.
AddForceDOS If True, force all filenames that go into
the ZIP file to meet the DOS 8x3 restriction.
If false, long filenames are supported.
WARNING: name conflicts can occur if 2 long
filenames reduce to the same 8x3 filename!
AddZipTime If True, set ZIP timestamp to that of the newest
file in the archive.
AddRecurseDirs If True, subdirectories below EACH given fspec
will be included in the fspec. Defaults to False.
This is potentially dangerous if the user does
this from the root directory (his hard drive
may fill up with a huge zip file)!
AddHiddenFiles If True, files with their Hidden or System
attributes set will be included in the Add
operation.
AddEncrypt If True, add the files with standard zip
encryption. You will be prompted for the
password to use.
NOTE: You can not have more than one of the following three options
set to "True". If all three are False, then you get a standard
"add": all files in the fspecs will be added to the archive
regardless of their date/time stamp. This is also the default.
AddMove If True, after adding to archive, delete orig
file. Potentially dangerous. Use with caution!
NOTE: Freshen and Update can only work on pre-existing archives. Update
can add new files to the archive, but can't create a new archive.
AddFreshen If True, add newer files to archive (only for
files that are already in the archive).
AddUpdate If True, add newer files to archive (but, any
file in an fspec that isn't already in the
archive will also be added).
ExtrBaseDir String This base directory applies only to "Extract"
operations. The UNZIP DLL will "CD" to this
directory before extracting any files. If you
don't specify a value for this property, then the
directory of the ZipFile itself will be the
base directory for extractions.
ExtrOptions Set This property is used to modify the default
action of the Extract method. This is a SET
of options. If you want an option to be
True, you need to add it to the set.
ExtrDirNames If True, extracts and recreates the relative
pathname that may have been stored with each file.
Empty dirs stored in the archive (if any) will
also be recreated.
ExtrOverWrite If True, overwrite any pre-existing files during
Extraction.
ExtrFreshen If True, extract newer files from archive (only
for files that already exist). Won't extract
any file that isn't already present.
ExtrUpdate If True, extract newer files from archive (but,
also extract files that don't already exist).
IMPORTANT! You must also set ExtrOverWrite if
you use this.
ExtrTest If True, only test the archive to see if the
files could be sucessfully extracted. This is
done by extracting the files, but NOT saving the
extracted data. Only the CRC code of the files
is used to determine if they are stored correctly.
To use this option, you will also need to define
an Event handler for OnMessage.
IMPORTANT: In this release, you must test all
files - not just some of them.
NOTE: there is no decryption property for extraction.
If an encrypted file is encountered, the user will be
automatically prompted for a password.
FSpecArgs TStrings Stringlist containing all the filespecs used
as arguments for Add, Delete, or Extract
methods. Every entry can contain MS-DOS wildcards.
If you give filenames without pathnames, or if
you use relative pathnames with filenames, then
the base drive/directory is assumed to be that
of the Zipfile.
ZipFilename String Pathname of a ZIP archive file. If the file
doesn't already exist, you will only be able to
use the Add method. I recommend using a fully
qualified pathname in this property, unless
your program can always ensure that a known
directory will be the "current" directory.
Count Integer Number of files now in the Zip file. Updated
automatically, or manually via the List method.
SuccessCnt Integer Number of files that were successfully
operated on (within the current ZIP file).
You can read this after every Add, Delete, and
Extract operation.
ZipVers Integer The version number of the ZIPDLL.DLL. For
example, 140 = version 1.40.
UnzVers Integer The version number of the UNZDLL.DLL. For
example, 140 = version 1.40.
Password String The user's encryption/decryption password.
This property is not needed if you want to
let the DLLs prompt the user for a password.
This is only used if you want to prompt the
user yourself.
WARNING! If you set the password in the
Object Inspector, and you never change the
password property at runtime, then your
users will never be able to use any other
password. If you leave it blank, the DLLs
will prompt users each time a password is
needed.
DLLDirectory String Allows manual specification of the directory
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 standard Windows search path will be
consulted, anyway.
SFXPath String Points to the ZIPSFX.BIN file. Must include
the whole pathname, filename, and extension.
This is only used by the ConvertSFX method.
As a convenience for you, ZipMaster will
look in the Windows dir, and in the Windows
System dir for this file, in case you don't
want to use this property.
SFXOverWriteMode enum This is the default overwrite option for what
the SFX program is supposed to do if it finds
files that already exist. If option
"SFXHideOverWriteBox" is true, then this option
will be used during extraction.
These are the possible values for this
property:
ovrConfirm - ask user when each file is found
ovrAlways - always overwrite existing files
ovrNever - never overwrite - skip those files
The default is "ovrConfirm".
SFXCaption String The caption of the SFX program's dialog box at
runtime. The default is 'Self-extracting Archive'.
SFXDefaultDir String The default target directory for extraction of
files at runtime. This can be changed at
runtime through the dialog box. If you don't
specify a value for this optional property, the
user's current directory will be the default.
SFXCommandLine String This command line will be executed immediately
after extracting the files. Typically used to
show the 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 (since the user can
always change your default).
Special symbols: "|" is the command/arg separator,
"><" is the actual extraction dir selected by user
Example:
notepad.exe|><readme.txt
Run notepad to show "readme.txt" in the actual
extraction directory.
This is an optional property.
SFXOptions Set This property is used to modify the default
action of the ConvertSFX method. This is a
SET of options. If you want an option to be
True, you need to add it to the set. This is
consistant with the way Delphi deals with
"options" properties in general.
SFXAskCmdLine If true, allows user (at runtime) to de-select
the SFX program's command line checkbox. Once
de-selected, the command line will not be run.
NOTE: The checkbox doesn't appear unless there
is a command line specified.
SFXAskFiles If true, lets user (at runtime) modify the
SFX program's list of files to be extracted.
SFXHideOverWriteBox If true, does NOT show the user (at runtime)
the SFX program's dialog box that lets him
choose the overwrite action for files that
already exist.
SFXCheckSize If true, check to make sure this archive was
not "cut short" before trying to expand the
files.
Events
======
OnDirUpdate Occurs immed. after this VCL refreshes it's
TZipContents TList. This is your queue to
update the screen with the new contents.
OnProgress Occurs during compression and decompression.
Intended for "status bar" or "progress bar"
updates. Criteria for this event:
- starting to process a new file (gives you
the filename and total uncompressed
filesize)
- every 32K bytes while processing
- completed processing on a batch of files
See Demo1 to learn how to use this event.
OnMessage Occurs when the DLL sends your program a message.
The Message argument passed by this event will
contain the message. If an error code
accompanies the message, it will be in the
ErrCode argument.
The Verbose and Trace properties have a
direct influence on how many OnMessage events
you'll get.
See Also: Message and ErrCode properties.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -