⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zipunzip.pas

📁 script language
💻 PAS
📖 第 1 页 / 共 4 页
字号:

   Methods
   =======
     Add                      Adds all files specified in the FSpecArgs
                              property into the archive specified by the
                              ZipFilename property.
                                Files that are already compressed will not be
                              compressed again, but will be stored "as is" in
                              the archive. This applies to .GIF, .ZIP, .LZH,
                              etc. files. Note that .JPG files WILL be
                              compressed, since they can still be squeezed
                              down in size by a notable margin.

     Extract                  Extracts all files specified in the FSpecArgs
                              property from the archive specified by the
                              ZipFilename property. If you don't specify
                              any FSpecArgs, then all files will be extracted.
                              Can also test the integrity of files in an
                              archive.
                                If you set the ExtrTest option of ExtrOptions,
                              then ALL files in the arive will be tested.
                              This will cause them to be extracted, but not
                              saved to the hard disk.  Their CRC will be
                              verified, and results will go to the SuccessCnt
                              property, and the OnMessage event handler.

     Delete                   Deletes all files specified in the FSpecArgs
                              property from the archive specified by the
                              ZipFilename property.

     List                     Refreshes the contents of the archive into
                              the ZipContents TList property.  This is
                              a manual "refresh" of the "Table of Contents".

     CopyFile                 This copies any file to any other file.
                              Useful in many application programs, so
                              it was included here as a method.  This returns
                              0 on success, or else one of these errors:
                                  -1   error in open of outfile
                                  -2   read or write error during copy
                                  -3   error in open of infile
                                  -4   error setting date/time of outfile
                                  -9   general failure during copy
                              Can be used to make a backup copy of the
                              ZipFile before an Add operation.
                              Sample Usage:
                                with ZipMaster1 do
                                begin
                                   ret = CopyFile( ZipFilename, 'C:\TMP$$.ZIP' );
                                   if ret < 0 then
                                      ShowMessage( 'Error making backup' );
                                end;

     NOTE: A -4 error is non-fatal.  The copied file will still be correct,
     except that the datetime stamp will be wrong.

     IMPORTANT note regarding CopyFile: The destination must include
     a filename (you can't copy fname.txt to C:\).  Also, Wildcards are
     not allowed in either source or dest.

     ------------------------------------------------------------------------

     Encrypted Archive Support

     Thanks to Mike Wilkey <mtw@allways.net> for his very useful source
     code and helpful comments.  He basically got this functionality
     working by himself.  I just plugged in his Result to TZipMaster.
     The source for the actual encryption algorithm is the overseas link
     pointed-to by InfoZip.  I have learned that this is NOT being controlled
     by the US government, so I am including it with this release.

     GetAddPassword           Prompt user for a password.  The password
                              will be accepted twice - the second time to
                              verify it.  If both of them match, it will
                              be saved in the Password property, or else
                              the Password property will be cleared.
                                The use of this method is not required.
                              If you want to make your own password prompt
                              dialog box, you can just put the password
                              into the password property yourself.  Also,
                              you can take the easiest route by leaving the
                              password property blank, and letting the
                              DLLs prompt the user for the password.

     GetExtrPassword          Prompt user for a password.  The password
                              will only be accepted once. It will be
                              saved in the Password property.
                                The use of this method is not required.
                              If you want to make your own password prompt
                              dialog box, you can just put the password
                              into the password property yourself.  Also,
                              you can take the easiest route by leaving the
                              password property blank, and letting the
                              DLLs prompt the user for the password.


     IMPORTANT notes about Password:

     - The "GetAddPassword" and "GetExtrPassword" methods are optional.
       You have 3 different ways of getting a user's password:

        1) Call the "GetAddPassword" and/or the "GetExtrPassword" methods,
           just before add or extract.

        2) Use your own code to set the "Password" property.  It's your
           choice how you obtain the password.
             - This is useful if the password comes from a file or table.
             - It's also good for letting you enforce constraints on the
           password - you can require it to be over 6 chars, require it
           to have at least one special char, etc.  Of course, you'd only
           want to enforce constrainst on "Add" operations.  A word of
           caution: many users don't like password constraints, so give
           them the option to turn them off.

        3) Don't set one at all, and let the DLLs prompt the user.
           It's easy, and it works.

     - Passwords can not be longer than 80 characters.  A zero-length
       password is the same as no password at all.

     - To "zero out" the password, set it's property to an empty string.
       If it is zero'd out, but the AddEncrypt option is set, then the
       user will be prompted for a new password by the DLLs. So, if you
       don't want a password used, make sure you turn off "AddEncrypt",
       and you zero-out the password.

     - If you set a password for an Extract, but it is incorrect, then
       the DLLs will NOT prompt the user for another password.

     - If the user enters a password at an automatic prompt generated
       by the DLL, then you can NOT get access to that password from
       your program.  If you want to know what it is, you need to prompt
       for it yourself.

     - To Force the DLL to AVOID decrypting an encrypted file, you must
       set the password property to an unlikely password (all periods,
       for example).  If adding, make sure AddEncrypt is NOT set.

     -------------------------------------------------------------------------

     Self Extracting Archive Support

     Thanks to Carl Bunton for the original SFX code.  This is a very big
     undertaking, and he did a great job.  He also makes good compression
     VCLs (called ZipTV) for Delphi.  They are shareware, but his profits
     go to a children's hospital.  He supports many archive formats, not
     just ZIP.  Check out his Web site:
                    http://www.ziptv.com/

     Currently, the SFX code is being maintained by Markus Stephany.
     His e-mail address is:  mirbir.st@t-online.de

     ConvertSFX               Convert zip archive to Self-extracting .EXE.
                              The resulting .EXE is a Win32 program.
                              Uses the same base name and path already
                              used by the zipfile - only the file extension
                              is changed to .EXE. This is accompished by
                              prepending the SFX code onto the front of
                              the zip file, and then changing it's extension.

     IMPORTANT! - before using ConvertSFX, you may want to first set the
       SFXPath property to the full pathname of the SFX code: ZIPSFX.BIN.
       If you don't set this property, ZipMaster will automatically look for
       this file in the Windows and Windows System directories.

     ConvertZIP               Convert Self-extracting .EXE to .ZIP archive.
                              Converts a Self-extracting .exe file into a
                              zip archive.  This is accomplished by removing
                              the SFX code from the beginning, and then
                              changing it's extension.

     WARNING: The use of ConvertZip can NOT be guaranteed to work with
        all Self-extracting archive formats.  It will work on MS-DOS "pkzip"
        (product of pkware) Self-extracting zip archives, and on those made
        by "WinZip" (product of Nikko Mak Computing), but some Self-extracting
        formats are not even based on zip compression.
           For example, the freeware "ASetup" program uses the .LZH
        compression format.  In fact, most setup programs use compression
        formats that aren't zip compatible.
           If you try to use ConvertZip on an archive that doesn't
        conform to the zip standard, you will get errors.  If fact, you
        can't even list the contents of an .EXE archive if it's not a
        standard zip format.

   --------------------------------------------------------------------

                       DLL Loading and Unloading

   This table show you which DLL is needed for each method:
       Add        requires ZIPDLL.DLL
       Delete     requires ZIPDLL.DLL
       Extract    requires UNZDLL.DLL
       List            none (internal code in this VCL)
       CopyFile        none (internal code in this VCL)
       GetAddPassword  none (internal code in this VCL)
       GetExtrPassword none (internal code in this VCL)
       ConvertSFX      none (internal code to this VCL)
       ConvertZIP      none (internal code to this VCL)
   NOTE: "Test" is a sub-option of extract.

   The following 4 methods give you explicit control over loading and
   unloading of the DLLs.  For simplicity, you can do the loads in
   your form's OnCreate event handler, and do the unloads in your
   form's OnDestroy event handler.

      Load_Zip_Dll    --  Loads ZIPDLL.DLL, if not already loaded
      Load_Unz_Dll    --  Loads UNZDLL.DLL, if not already loaded
      Unload_Zip_Dll  --  Unloads ZIPDLL.DLL
      Unload_Unz_Dll  --  Unloads UNZDLL.DLL

   For compatibility with older programs, and because I'm a nice
   guy, I'll handle the loads and unloads automatically if your
   program doesn't do it.  This can, however, incur a perfomance
   penalty because it will reload the needed DLL for each operation.

   Advanced developers will want to carefully consider their load
   and unload strategy so they minimize the number of loads, and
   keep the DLLs out of memory when they're not needed. There is a
   traditional speed vs. memory trade-off.
  --------------------------------------------------------------------
*)

// VER80 = Delphi 1 but DelZip is not made for it.

{$IfDef VER90}
   {$Define KNOWNCOMPILER}
   {$Define DELPHI}
   {$Define VERD2D3}
{$EndIf}
{$IfDef VER93}
   {$DEFINE KNOWNCOMPILER}
   {$DEFINE CBUILDER}
   {$DEFINE CBUILDER1}
{$EndIf}
{$IfDef VER100}
   {$DEFINE KNOWNCOMPILER}
   {$DEFINE DELPHI}
   {$DEFINE DELPHI3}
   {$Define VERD2D3}
{$EndIf}
{$IfDef VER110}
   {$DEFINE KNOWNCOMPILER}
   {$DEFINE CBUILDER}
牋 {$ObjExportAll On}
   {$DEFINE CBUILDER3}
{$EndIf}
{$IfDef VER120}
   {$DEFINE KNOWNCOMPILER}
   {$DEFINE DELPHI}
   {$DEFINE DELPHI4}
   {$Define VERD4+}
{$EndIf}
{$IfDef VER125}
   {$DEFINE KNOWNCOMPILER}
   {$DEFINE CBUILDER}
   {$DEFINE CBUILDER4}
   {$ObjExportAll On}
   {$DEFINE VERD4+}
{$EndIf}
{$IfDef VER130}
 {$IfNDef BCB}
   {$DEFINE KNOWNCOMPILER}
   {$DEFINE DELPHI}
   {$DEFINE DELPHI5}
   {$Define VERD4+}
 {$EndIf}
{$EndIf}
{$IfDef VER130}
 {$IfDef BCB}
   {$DEFINE KNOWNCOMPILER}
   {$DEFINE CBUILDER}
   {$DEFINE CBUILDER5}
牋 {$ObjExportAll On}
   {$DEFINE VERD4+}
 {$EndIf}
{$EndIf}
{$IfDef VER140}
 {$IfNDef BCB}
   {$DEFINE KNOWNCOMPILER}
   {$DEFINE DELPHI}
   {$DEFINE DELPHI6}
   {$Define VERD4+}
 {$EndIf}
{$EndIf}


{.$DEFINE KNOWNCOMPILER}
{$IfNDef KNOWNCOMPILER}
YOU ARE USING A COMPILER FOR WHICH THIS PACKAGE IS NOT YET DESIGNED!

YOU SHOULD ADD A COMPILER DEFINITION FIRST TO THE FILE ZipVers.inc

YOU CAN REMOVE THIS ERROR MESSAGE BY REMOVING THE DOT (.) ON THE LINE
"{.$DEFINE KNOWNCOMPILER}"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -