How to Use LZCOPYFILE Function to Decompress or Copy Files

ID: Q88257


The information in this article applies to:


SUMMARY

Included with Windows versions 3.0 and 3.1 is a dynamic-link library (DLL) named LZEXPAND.DLL that contains routines to manipulate compressed files. The functions in LZEXPAND.DLL manipulate files that are compressed by the COMPRESS.EXE utility supplied with the Windows Software Development Kit (SDK) versions 3.0 and 3.1. These functions allow you to expand (decompress) a compressed file.

The following example demonstrates how to use the LZCOPYFILE function included in LZEXPAND.DLL. This function is used to expand a compressed file or to copy a file.


MORE INFORMATION

The following is a small program that will copy or decompress a file in Visual Basic for Windows:

  1. Start Visual Basic or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default.


  2. In the general Declarations section of Form1, add the following declaration entirely on one, single line:
    
       Declare Function LZCOPY Lib "LZEXPAND.DLL" (ByVal SOURCEHANDLE As
          Integer, ByVal DESTHANDLE As Integer) As Long
     


  3. In the Form1 Click event procedure, add the following code:
    
       Open "Source" For Input As #1 ' Insert the name and path of the
                                     ' file to be decompressed, or copied.
    
       Open "Dest" For Output As #2  ' Insert the name and path of the
                                     ' destination file here.
       SOURCEHANDLE% = Fileattr(1,2)
       DESTHANDLE% = Fileattr(2,2)
       RETURNCODE& = Lzcopy(Sourcehandle%, Desthandle%)
       Close
     


  4. From the Run menu, choose Start (ALT, R, S) to run the program.


The return code will be set to the number of bytes copied or set to the following value if an error occurs:
-1 invalid input handle
-2 invalid output handle
-3 corrupt compressed file format
-4 out of space for output file
-5 insufficient memory for LZFile struct
-6 bad global handle
-7 input parameter out of range
-8 compression algorithm not recognized

Additional query words: 2.00 3.00


Keywords          : 
Version           : 
Platform          : 
Issue type        : 

Last Reviewed: June 21, 1999