How to Use LZCOPYFILE Function to Decompress or Copy Files

Last reviewed: June 21, 1995
Article ID: Q88257
The information in this article applies to:
  • Standard and Professional Editions of Microsoft Visual Basic for Windows, versions 2.0 and 3.0
  • Microsoft Visual Basic programming system for Windows, version 1.0

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 reference words: 1.00 2.00 3.00
KBCategory: kbprg
KBSubcategory: APrgOther


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.