Menu

Zip and Unzip DLL - easy to use from LotusScript or VB

Update: March, 26th, 2009: VCZipSup has been updated to version 1.2 due to a bug in Unzip. Please enjoy!

Do you need zip and/or unzip support in LotusScript? Download this free DLL and off you go :-)

The VCZipSup attachment contains a single 32-bit Windows DLL with the following two main functions Zip and Unzip. Their purpose is of course to zip or unzip ordinary zip files. At the moment their features are limited to only zip and unzip without advanced features such as encryption.

Installation

Simply extract DLL into a directory specified in your PATH environment variable, such as C:\Windows or C:\Windows\System32. Since the DLL must be found by LotusScript during runtime, it must exist in a directory specified in one of those PATH-variable directories, especially if you want to declare the function by just using the name "VCZIPSUP.DLL".

Alternativly you may store the DLL in any directory, but then your Declare-statement must be specific such as Declare Function Zip Lib "C:\My VCZIPSUP Directory\VCZIPSUP.DLL"

Usage

Zip

The purpose of the Zip function is to store other files inside a so-called zip archive file. The generated zip file is fully compatible with other zip tools on the marked, such as WinZip, WinRAR or the built-in zip support in Windows itself.

You can easily use these functions from Visual Basic languages such as LotusScript, using the Declare statement.

Declare Function Zip Lib "VCZIPSUP.DLL" (_
Byval pstrInputDirectory As String, _
Byval pstrFileWildCardSpec As String, _
Byval pstrOutputZipFilename As String, _
Byval iIncludeSubDirs As Integer, _
Byval iKeepFolderStructure As Integer, _
Byval pstrOptions As String) As Long

The parameters are;
Parameter Description
pstrInputDirectory String. The path to the input directory without a trailing backslash, for example "C:\My files"
pstrFileWildCardSpec String. The wild card specification for files to include in the zip file, such as "*.*" to include all files within the directory, or for example "*.pdf" to include just PDF files
pstrOutputZipFilename String. Full path and filename to the output zip file, such as "C:\Temp\My Zip file.zip"
iIncludeSubDirs Integer. Specify 1 to traverse sub directories or 0 to just include files in the directory specified by the parameters pstrInputDirectory  and pstrFileWildCardSpec
iKeepFolderStructure Integer. Not in use in this version, just specify 0
pstrOptions String. Not in use in this version. Just specify empty string ""


The return code is 0 if everything is OK. All other numbers are failure!

Example:

Sub Initialize
        Dim lRc As Long
        lRc = Zip("D:\Temp\Files","*.*", "D:\Temp\MyFirstZipFile.zip",1, 0,"")
End Sub

The example above will zip all files (*.*) in the directory D:\Temp\Files. All files in this directory and any subdirectories will be outputted into the D:\Temp\MyFirstZipFile.zip.

Please note that the Zip function will overwrite any existing zip file with the same name. It is up to you to check whether the output zip file exists or not before calling the Zip-function.

Unzip

Unzipping is the opposite operation of zipping, which means unpacking an existing zip file. The result is all the files contained in the zip file in a directory

You declare the unzip function like this;

Declare Function Unzip Lib "VCZIPSUP.DLL" (_
Byval pstrInputZipFilename As String, _
Byval pstrOutputDirectory As String, _
Byval pstrOptions As String) As Long

The parameters are;
Parameter Description
pstrInputZipFilename String. The full path and filename to zip file to unzip.
pstrOutputDirectory String. Full path to the directory where you want to store the files contained in the zip file
pstrOptions String. Not in use in this version. Just specify empty string ""


The return code is 0 if everything is OK. All other numbers are failure!

GetZIPSUPMajorVersion, GetZIPSUPMinorVersion and GetZIPSUPBuildNumber

In order to aid you with different versions of VCZIPSUP, you can also declare and use the three GetZIPSUPxxx functions to determine the installed version of VCZIPSUP.DLL on your system. You declare them like this;

Declare Function GetZIPSUPMajorVersion Lib "VCZIPSUP.DLL" () As Integer
Declare Function GetZIPSUPMinorVersion Lib "VCZIPSUP.DLL" () As Integer
Declare Function GetZIPSUPBuildNumber Lib "VCZIPSUP.DLL" () As Integer

Hope you enjoy this free DLL!