Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6724 → Rev 6725

/programs/fs/unzip60/windll/vb/VBReadMe.txt
0,0 → 1,50
On Windows, please read this file using WordPad to format lines properly.
 
This directory contains a short example on how to use the Win32 UnZip DLL
with Visual Basic. The example code consists of a simple dialog form and
a standard module containing the interface code to call unzip32.dll.
The code assumes that the unzip32.dll binary is available somewhere on the
execution path. The easiest way to satisfy this rule is to keep a copy of
unzip32.dll in the directory where the VB executable is stored, but if
it's in the command path it should be found.
NOTE: Whenever a VB program is run from the VB6 IDE, the "path of the VB
executable" is the path where the IDE program file "VB6.EXE" is stored,
NOT the storage directory of the VB project file (= result of the App.Path
property accessed from within the VB program).
 
The example code has been edited last with Visual Basic 6, but should be
compatible with VB 5. To maintain compatibility with VB5 after having modified
the example project in VB6, the project file has to be edited using a standard
text editor (e.g.: Notepad), to remove the line specifying the "Retained"
property. This property line is not recognized by VB 5 and would prevent
correct loading of the project in VB 5.
 
This VB example makes use of the "Windows Common Dialogs" ActiveX control
comdlg32.ocx, supplied with Visual Basic. Unfortunately, there are different
revisions of this control available which are not binary compatible. In order
to maintain compatibility of the source code with all available versions of
comdlg32.ocx, the source files may have to be edited manually after the
program has been saved from the VB environment on a system containing the
latest release of comdlg32.ocx:
 
Both vbunzip.frm and vbunzip.vbp should contain a reference line for the
common dialog ocx reading like:
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
^^^
The important section of this line is the revision number "1.1" (marked by
the "^^^" signs). On a system with a more recent version of comdlg32.ocx
installed, this version number is updated to "1.2" (or higher) by VB
automatically. This number has to be changed back to "1.1" manually,
otherwise the example code can no longer be used on systems with old versions
of comdlg32.ocx.
 
When fetching the VB example code from the UnZip source distribution, one
has to make sure that the files are stored in the correct "DOS/Windows-native"
text format with "CR-LF" line endings. Visual Basic does not accept Unix style
text format (LF line terminators) for Form class modules (*.frm) and the
project file (*.vbp). You may use unzip's -a option to convert the project
on extraction. If this is a full source distribution, see the Where file for
where to download the compiled unzip DLL for a specific platform which includes
this example project in native format for that platform.
 
For more information, see the comments within the VB source.
/programs/fs/unzip60/windll/vb/vbunzip.bas
0,0 → 1,714
Attribute VB_Name = "VBUnzBas"
Option Explicit
 
'-- Please Do Not Remove These Comment Lines!
'----------------------------------------------------------------
'-- Sample VB 5 / VB 6 code to drive unzip32.dll
'-- Contributed to the Info-ZIP project by Mike Le Voi
'--
'-- Contact me at: mlevoi@modemss.brisnet.org.au
'--
'-- Visit my home page at: http://modemss.brisnet.org.au/~mlevoi
'--
'-- Use this code at your own risk. Nothing implied or warranted
'-- to work on your machine :-)
'----------------------------------------------------------------
'--
'-- This Source Code Is Freely Available From The Info-ZIP Project
'-- Web Server At:
'-- ftp://ftp.info-zip.org/pub/infozip/infozip.html
'--
'-- A Very Special Thanks To Mr. Mike Le Voi
'-- And Mr. Mike White
'-- And The Fine People Of The Info-ZIP Group
'-- For Letting Me Use And Modify Their Original
'-- Visual Basic 5.0 Code! Thank You Mike Le Voi.
'-- For Your Hard Work In Helping Me Get This To Work!!!
'---------------------------------------------------------------
'--
'-- Contributed To The Info-ZIP Project By Raymond L. King.
'-- Modified June 21, 1998
'-- By Raymond L. King
'-- Custom Software Designers
'--
'-- Contact Me At: king@ntplx.net
'-- ICQ 434355
'-- Or Visit Our Home Page At: http://www.ntplx.net/~king
'--
'---------------------------------------------------------------
'--
'-- Modified August 17, 1998
'-- by Christian Spieler
'-- (implemented sort of a "real" user interface)
'-- Modified May 11, 2003
'-- by Christian Spieler
'-- (use late binding for referencing the common dialog)
'-- Modified February 01, 2008
'-- by Christian Spieler
'-- (adapted DLL interface changes, fixed UZDLLPass callback)
'-- Modified December 08, 2008 to December 30, 2008
'-- by Ed Gordon
'-- Updated sample project for UnZip 6.0 unzip32.dll
'-- (support UnZip 6.0 flags and structures)
'-- Modified January 03, 2009
'-- by Christian Spieler
'-- (better solution for overwrite_all handling, use Double
'-- instead of Currency to stay safe against number overflow,
'-- corrected UZDLLServ_I32() calling interface,
'-- removed code that is unsupported under VB5)
'--
'---------------------------------------------------------------
 
'-- Expected Version data for the DLL compatibility check
'
' For consistency of the version checking algorithm, the version number
' constants "UzDLL_MinVer" and "UzDLL_MaxAPI" have to fullfil the
' condition "UzDLL_MinVer <= "UzDLL_MaxAPI".
' Version data supplied by a specific UnZip DLL always obey the
' relation "UzDLL Version" >= "UzDLL API".
 
'Oldest UnZip DLL version that is supported by this program
Private Const cUzDLL_MinVer_Major As Byte = 6
Private Const cUzDLL_MinVer_Minor As Byte = 0
Private Const cUzDLL_MinVer_Revis As Byte = 0
 
'Last (newest) UnZip DLL API version that is known (and supported)
'by this program
Private Const cUzDLL_MaxAPI_Major As Byte = 6
Private Const cUzDLL_MaxAPI_Minor As Byte = 0
Private Const cUzDLL_MaxAPI_Revis As Byte = 0
 
'Current structure version ID of the DCLIST structure layout
Private Const cUz_DCLStructVer As Long = &H600
 
'-- C Style argv
Private Type UNZIPnames
uzFiles(0 To 99) As String
End Type
 
'-- Callback Large "String"
Private Type UNZIPCBChar
ch(32800) As Byte
End Type
 
'-- Callback Small "String"
Private Type UNZIPCBCh
ch(256) As Byte
End Type
 
'-- UNZIP32.DLL DCL Structure
Private Type DCLIST
StructVersID As Long ' Currently version &H600 of this structure
ExtractOnlyNewer As Long ' 1 = Extract Only Newer/New, Else 0
SpaceToUnderscore As Long ' 1 = Convert Space To Underscore, Else 0
PromptToOverwrite As Long ' 1 = Prompt To Overwrite Required, Else 0
fQuiet As Long ' 2 = No Messages, 1 = Less, 0 = All
ncflag As Long ' 1 = Write To Stdout, Else 0
ntflag As Long ' 1 = Test Zip File, Else 0
nvflag As Long ' 0 = Extract, 1 = List Zip Contents
nfflag As Long ' 1 = Extract Only Newer Over Existing, Else 0
nzflag As Long ' 1 = Display Zip File Comment, Else 0
ndflag As Long ' 0 = Junk paths, 1 = safe path components only, 2 = all
noflag As Long ' 1 = Overwrite Files, Else 0
naflag As Long ' 1 = Convert CR To CRLF, Else 0
nZIflag As Long ' 1 = Zip Info Verbose, Else 0
B_flag As Long ' 1 = Backup existing files, Else 0
C_flag As Long ' 1 = Case Insensitivity, 0 = Case Sensitivity
D_flag As Long ' Timestamp restoration, 0 = All, 1 = Files, 2 = None
U_flag As Long ' 0 = Unicode enabled, 1 = Escape chars, 2 = No Unicode
fPrivilege As Long ' 1 = ACL, 2 = Privileges
Zip As String ' The Zip Filename To Extract Files
ExtractDir As String ' The Extraction Directory, NULL If Extracting To Current Dir
End Type
 
'-- UNZIP32.DLL Userfunctions Structure
Private Type USERFUNCTION
UZDLLPrnt As Long ' Pointer To Apps Print Function
UZDLLSND As Long ' Pointer To Apps Sound Function
UZDLLREPLACE As Long ' Pointer To Apps Replace Function
UZDLLPASSWORD As Long ' Pointer To Apps Password Function
' 64-bit versions (VB6 does not support passing 64-bit values!)
UZDLLMESSAGE As Long ' Pointer To Apps Message Function (Not Used!)
UZDLLSERVICE As Long ' Pointer To Apps Service Function (Not Used!)
' 32-bit versions
UZDLLMESSAGE_I32 As Long ' Pointer To Apps Message Function
UZDLLSERVICE_I32 As Long ' Pointer To Apps Service Function
' All 64-bit values passed as low and high parts!
TotalSizeComp_Lo As Long ' Total Size Of Zip Archive (low 32 bits)
TotalSizeComp_Hi As Long ' Total Size Of Zip Archive (high 32 bits)
TotalSize_Lo As Long ' Total Size Of All Files In Archive (low 32)
TotalSize_Hi As Long ' Total Size Of All Files In Archive (high 32)
NumMembers_Lo As Long ' Total Number Of All Files In The Archive (low 32)
NumMembers_Hi As Long ' Total Number Of All Files In The Archive (high 32)
CompFactor As Long ' Compression Factor
cchComment As Integer ' Flag If Archive Has A Comment!
End Type
 
'-- UNZIP32.DLL Version Structure
Private Type UZPVER2
structlen As Long ' Length Of The Structure Being Passed
flag As Long ' Bit 0: is_beta bit 1: uses_zlib
beta As String * 10 ' e.g., "g BETA" or ""
date As String * 20 ' e.g., "4 Sep 95" (beta) or "4 September 1995"
zlib As String * 10 ' e.g., "1.0.5" or NULL
unzip(1 To 4) As Byte ' Version Type Unzip
zipinfo(1 To 4) As Byte ' Version Type Zip Info
os2dll As Long ' Version Type OS2 DLL
windll(1 To 4) As Byte ' Version Type Windows DLL
dllapimin(1 To 4) As Byte ' Version Type DLL API minimum compatibility
End Type
 
'-- This assumes UNZIP32.DLL is somewhere on your execution path!
'-- The term "execution path" means a search in the following locations,
'-- in the listed sequence (for more details look up the documentation
'-- of the LoadLibrary() Win32 API call):
'-- 1) the directory from which the VB6 application was loaded,
'-- 2) your current working directory in effect when the VB6 program
'-- tries to access a first API call of UNZIP32.DLL,
'-- 3) the Windows "SYSTEM32" (only NT/2K/XP...) and "SYSTEM" directories,
'-- and the Windows directory,
'-- 4) the folder list of your command path (e.g. check the environment
'-- variable PATH as set in a console window started from scratch).
'-- Normally, the Windows system directory is on your command path,
'-- so installing the UNZIP32.DLL in the Windows System Directory
'-- should always work.
'--
'-- WARNING:
'-- When a VB6 program is run in the VB6 IDE, the "directory from which the
'-- application was loaded" is the
'-- ===>>> directory where VB6.EXE is stored (!!!),
'-- not the storage directory of the VB project file
'-- (the folder returned by "App.Path").
'-- When a compiled VB6 program is run, the "application load directory"
'-- is identical with the folder reported by "App.Path".
'--
Private Declare Function Wiz_SingleEntryUnzip Lib "unzip32.dll" _
(ByVal ifnc As Long, ByRef ifnv As UNZIPnames, _
ByVal xfnc As Long, ByRef xfnv As UNZIPnames, _
dcll As DCLIST, Userf As USERFUNCTION) As Long
 
Private Declare Function UzpVersion2 Lib "unzip32.dll" _
(uzpv As UZPVER2) As Long
 
'-- Private variable holding the API version id as reported by the
'-- loaded UnZip DLL
Private m_UzDllApiVers As Long
 
'-- Private Variables For Structure Access
Private UZDCL As DCLIST
Private UZUSER As USERFUNCTION
Private UZVER2 As UZPVER2
 
'-- Public Variables For Setting The
'-- UNZIP32.DLL DCLIST Structure
'-- These Must Be Set Before The Actual Call To VBUnZip32
Public uExtractOnlyNewer As Long ' 1 = Extract Only Newer/New, Else 0
Public uSpaceUnderScore As Long ' 1 = Convert Space To Underscore, Else 0
Public uPromptOverWrite As Long ' 1 = Prompt To Overwrite Required, Else 0
Public uQuiet As Long ' 2 = No Messages, 1 = Less, 0 = All
Public uWriteStdOut As Long ' 1 = Write To Stdout, Else 0
Public uTestZip As Long ' 1 = Test Zip File, Else 0
Public uExtractList As Long ' 0 = Extract, 1 = List Contents
Public uFreshenExisting As Long ' 1 = Update Existing by Newer, Else 0
Public uDisplayComment As Long ' 1 = Display Zip File Comment, Else 0
Public uHonorDirectories As Long ' 1 = Honor Directories, Else 0
Public uOverWriteFiles As Long ' 1 = Overwrite Files, Else 0
Public uConvertCR_CRLF As Long ' 1 = Convert CR To CRLF, Else 0
Public uVerbose As Long ' 1 = Zip Info Verbose
Public uCaseSensitivity As Long ' 1 = Case Insensitivity, 0 = Case Sensitivity
Public uPrivilege As Long ' 1 = ACL, 2 = Privileges, Else 0
Public uZipFileName As String ' The Zip File Name
Public uExtractDir As String ' Extraction Directory, Null If Current Directory
 
'-- Public Program Variables
Public uZipNumber As Long ' Zip File Number
Public uNumberFiles As Long ' Number Of Files
Public uNumberXFiles As Long ' Number Of Extracted Files
Public uZipMessage As String ' For Zip Message
Public uZipInfo As String ' For Zip Information
Public uZipNames As UNZIPnames ' Names Of Files To Unzip
Public uExcludeNames As UNZIPnames ' Names Of Zip Files To Exclude
Public uVbSkip As Boolean ' For DLL Password Function
 
'-- Puts A Function Pointer In A Structure
'-- For Callbacks.
Public Function FnPtr(ByVal lp As Long) As Long
 
FnPtr = lp
 
End Function
 
'-- Callback For UNZIP32.DLL - Receive Message Function
Public Sub UZReceiveDLLMessage_I32( _
ByVal ucsize_lo As Long, _
ByVal ucsize_hi As Long, _
ByVal csiz_lo As Long, _
ByVal csiz_hi As Long, _
ByVal cfactor As Integer, _
ByVal mo As Integer, _
ByVal dy As Integer, _
ByVal yr As Integer, _
ByVal hh As Integer, _
ByVal mm As Integer, _
ByVal c As Byte, _
ByRef fname As UNZIPCBCh, _
ByRef meth As UNZIPCBCh, _
ByVal crc As Long, _
ByVal fCrypt As Byte)
 
Dim s0 As String
Dim xx As Long
Dim cCh As Byte
Dim strout As String * 80
Dim ucsize As Double
Dim csiz As Double
 
'-- Always implement a runtime error handler in Callback Routines!
On Error Resume Next
 
'------------------------------------------------
'-- This Is Where The Received Messages Are
'-- Printed Out And Displayed.
'-- You Can Modify Below!
'------------------------------------------------
 
strout = Space$(80)
 
'-- For Zip Message Printing
If uZipNumber = 0 Then
Mid$(strout, 1, 50) = "Filename:"
Mid$(strout, 53, 4) = "Size"
Mid$(strout, 62, 4) = "Date"
Mid$(strout, 71, 4) = "Time"
uZipMessage = strout & vbNewLine
strout = Space$(80)
End If
 
s0 = ""
 
'-- Do Not Change This For Next!!!
For xx = 0 To UBound(fname.ch)
If fname.ch(xx) = 0 Then Exit For
s0 = s0 & Chr$(fname.ch(xx))
Next
 
ucsize = CnvI64Struct2Dbl(ucsize_lo, ucsize_hi)
csiz = CnvI64Struct2Dbl(csiz_lo, csiz_hi)
 
'-- Assign Zip Information For Printing
Mid$(strout, 1, 50) = Mid$(s0, 1, 50)
Mid$(strout, 51, 9) = Right$(" " & CStr(ucsize), 9)
Mid$(strout, 62, 3) = Right$("0" & Trim$(CStr(mo)), 2) & "/"
Mid$(strout, 65, 3) = Right$("0" & Trim$(CStr(dy)), 2) & "/"
Mid$(strout, 68, 2) = Right$("0" & Trim$(CStr(yr)), 2)
Mid$(strout, 72, 3) = Right$(Str$(hh), 2) & ":"
Mid$(strout, 75, 2) = Right$("0" & Trim$(CStr(mm)), 2)
 
' Mid$(strout, 77, 2) = Right$(" " & CStr(cfactor), 2)
' Mid$(strout, 80, 8) = Right$(" " & CStr(csiz), 8)
' s0 = ""
' For xx = 0 To 255
' If meth.ch(xx) = 0 Then Exit For
' s0 = s0 & Chr$(meth.ch(xx))
' Next xx
 
'-- Do Not Modify Below!!!
uZipMessage = uZipMessage & strout & vbNewLine
uZipNumber = uZipNumber + 1
 
End Sub
 
'-- Callback For UNZIP32.DLL - Print Message Function
Public Function UZDLLPrnt(ByRef fname As UNZIPCBChar, ByVal x As Long) As Long
 
Dim s0 As String
Dim xx As Long
Dim cCh As Byte
 
'-- Always implement a runtime error handler in Callback Routines!
On Error Resume Next
 
s0 = ""
 
'-- Gets The UNZIP32.DLL Message For Displaying.
For xx = 0 To x - 1
cCh = fname.ch(xx)
Select Case cCh
Case 0
Exit For
Case 10
s0 = s0 & vbNewLine ' Damn UNIX :-)
Case 92 ' = Asc("\")
s0 = s0 & "/"
Case Else
s0 = s0 & Chr$(cCh)
End Select
Next
 
'-- Assign Zip Information
uZipInfo = uZipInfo & s0
 
UZDLLPrnt = 0
 
End Function
 
'-- Callback For UNZIP32.DLL - DLL Service Function
Public Function UZDLLServ_I32(ByRef mname As UNZIPCBChar, _
ByVal lUcSiz_Lo As Long, ByVal lUcSiz_Hi As Long) As Long
 
Dim UcSiz As Double
Dim s0 As String
Dim xx As Long
 
'-- Always implement a runtime error handler in Callback Routines!
On Error Resume Next
 
' Parameters lUcSiz_Lo and lUcSiz_Hi contain the uncompressed size
' of the extracted archive entry.
' This information may be used for some kind of progress display...
UcSiz = CnvI64Struct2Dbl(lUcSiz_Lo, lUcSiz_Hi)
 
s0 = ""
'-- Get Zip32.DLL Message For processing
For xx = 0 To UBound(mname.ch)
If mname.ch(xx) = 0 Then Exit For
s0 = s0 & Chr$(mname.ch(xx))
Next
' At this point, s0 contains the message passed from the DLL
' (like the current file being extracted)
' It is up to the developer to code something useful here :)
 
UZDLLServ_I32 = 0 ' Setting this to 1 will abort the zip!
 
End Function
 
'-- Callback For UNZIP32.DLL - Password Function
Public Function UZDLLPass(ByRef pwbuf As UNZIPCBCh, _
ByVal bufsiz As Long, ByRef promptmsg As UNZIPCBCh, _
ByRef entryname As UNZIPCBCh) As Long
 
Dim prompt As String
Dim xx As Long
Dim szpassword As String
 
'-- Always implement a runtime error handler in Callback Routines!
On Error Resume Next
 
UZDLLPass = -1 'IZ_PW_CANCEL
 
If uVbSkip Then Exit Function
 
'-- Get the Password prompt
For xx = 0 To UBound(promptmsg.ch)
If promptmsg.ch(xx) = 0 Then Exit For
prompt = prompt & Chr$(promptmsg.ch(xx))
Next
If Len(prompt) = 0 Then
prompt = "Please Enter The Password!"
Else
prompt = prompt & " "
For xx = 0 To UBound(entryname.ch)
If entryname.ch(xx) = 0 Then Exit For
prompt = prompt & Chr$(entryname.ch(xx))
Next
End If
 
'-- Get The Zip File Password
Do
szpassword = InputBox(prompt)
If Len(szpassword) < bufsiz Then Exit Do
' -- Entered password exceeds UnZip's password buffer size
If MsgBox("The supplied password exceeds the maximum password length " _
& CStr(bufsiz - 1) & " supported by the UnZip DLL." _
, vbExclamation + vbRetryCancel, "UnZip password too long") _
= vbCancel Then
szpassword = ""
Exit Do
End If
Loop
 
'-- No Password So Exit The Function
If Len(szpassword) = 0 Then
uVbSkip = True
Exit Function
End If
 
'-- Zip File Password So Process It
For xx = 0 To bufsiz - 1
pwbuf.ch(xx) = 0
Next
'-- Password length has already been checked, so
'-- it will fit into the communication buffer.
For xx = 0 To Len(szpassword) - 1
pwbuf.ch(xx) = Asc(Mid$(szpassword, xx + 1, 1))
Next
 
pwbuf.ch(xx) = 0 ' Put Null Terminator For C
 
UZDLLPass = 0 ' IZ_PW_ENTERED
 
End Function
 
'-- Callback For UNZIP32.DLL - Report Function To Overwrite Files.
'-- This Function Will Display A MsgBox Asking The User
'-- If They Would Like To Overwrite The Files.
Public Function UZDLLReplacePrmt(ByRef fname As UNZIPCBChar, _
ByVal fnbufsiz As Long) As Long
 
Dim s0 As String
Dim xx As Long
Dim cCh As Byte
Dim bufmax As Long
 
'-- Always implement a runtime error handler in Callback Routines!
On Error Resume Next
 
UZDLLReplacePrmt = 100 ' 100 = Do Not Overwrite - Keep Asking User
s0 = ""
bufmax = UBound(fname.ch)
If bufmax >= fnbufsiz Then bufmax = fnbufsiz - 1
 
For xx = 0 To bufmax
cCh = fname.ch(xx)
Select Case cCh
Case 0
Exit For
Case 92 ' = Asc("\")
s0 = s0 & "/"
Case Else
s0 = s0 & Chr$(cCh)
End Select
Next
 
'-- This Is The MsgBox Code
xx = MsgBox("Overwrite """ & s0 & """ ?", vbExclamation Or vbYesNoCancel, _
"VBUnZip32 - File Already Exists!")
Select Case xx
Case vbYes
UZDLLReplacePrmt = 102 ' 102 = Overwrite, 103 = Overwrite All
Case vbCancel
UZDLLReplacePrmt = 104 ' 104 = Overwrite None
Case Else
'keep the default as set at function entry.
End Select
 
End Function
 
'-- ASCIIZ To String Function
Public Function szTrim(szString As String) As String
 
Dim pos As Long
 
pos = InStr(szString, vbNullChar)
 
Select Case pos
Case Is > 1
szTrim = Trim$(Left$(szString, pos - 1))
Case 1
szTrim = ""
Case Else
szTrim = Trim$(szString)
End Select
 
End Function
 
'-- convert a 64-bit int divided in two Int32 variables into
'-- a single 64-bit floating-point value
Private Function CnvI64Struct2Dbl(ByVal lInt64Lo As Long, lInt64Hi As Long) As Double
If lInt64Lo < 0 Then
CnvI64Struct2Dbl = 2# ^ 32 + CDbl(lInt64Lo)
Else
CnvI64Struct2Dbl = CDbl(lInt64Lo)
End If
CnvI64Struct2Dbl = CnvI64Struct2Dbl + (2# ^ 32) * CDbl(lInt64Hi)
End Function
 
'-- Concatenate a "structured" version number into a single integer value,
'-- to facilitate version number comparisons
'-- (In case the practically used NumMajor numbers will ever exceed 128, it
'-- should be considered to use the number type "Double" to store the
'-- concatenated number. "Double" can store signed integer numbers up to a
'-- width of 52 bits without loss of precision.)
Private Function ConcatVersNums(ByVal NumMajor As Byte, ByVal NumMinor As Byte _
, ByVal NumRevis As Byte, ByVal NumBuild As Byte) As Long
If (NumMajor And &H80) <> 0 Then
ConcatVersNums = (NumMajor And &H7F) * (2 ^ 24) Or &H80000000
Else
ConcatVersNums = NumMajor * (2 ^ 24)
End If
ConcatVersNums = ConcatVersNums _
+ NumMinor * (2 ^ 16) _
+ NumRevis * (2 ^ 8) _
+ NumBuild
End Function
 
'-- Helper function to provide a printable version number string, using the
'-- current formatting rule for version number display as implemented in UnZip.
Private Function VersNumsToTxt(ByVal NumMajor As Byte, ByVal NumMinor As Byte _
, ByVal NumRevis As Byte) As String
VersNumsToTxt = CStr(NumMajor) & "." & Hex$(NumMinor)
If NumRevis <> 0 Then VersNumsToTxt = VersNumsToTxt & Hex$(NumRevis)
End Function
 
'-- Helper function to convert a "concatenated" version id into a printable
'-- version number string, using the current formatting rule for version number
'-- display as implemented in UnZip.
Private Function VersIDToTxt(ByVal VersionID As Long) As String
Dim lNumTemp As Long
 
lNumTemp = VersionID \ (2 ^ 24)
If lNumTemp < 0 Then lNumTemp = 256 + lNumTemp
VersIDToTxt = CStr(lNumTemp) & "." _
& Hex$((VersionID And &HFF0000) \ &H10000)
lNumTemp = (VersionID And &HFF00&) \ &H100
If lNumTemp <> 0 Then VersIDToTxt = VersIDToTxt & Hex$(lNumTemp)
End Function
 
'-- Main UNZIP32.DLL UnZip32 Subroutine
'-- (WARNING!) Do Not Change!
Public Sub VBUnZip32()
 
Dim retcode As Long
Dim MsgStr As String
Dim TotalSizeComp As Double
Dim TotalSize As Double
Dim NumMembers As Double
 
'-- Set The UNZIP32.DLL Options
'-- (WARNING!) Do Not Change
UZDCL.StructVersID = cUz_DCLStructVer ' Current version of this structure
UZDCL.ExtractOnlyNewer = uExtractOnlyNewer ' 1 = Extract Only Newer/New
UZDCL.SpaceToUnderscore = uSpaceUnderScore ' 1 = Convert Space To Underscore
UZDCL.PromptToOverwrite = uPromptOverWrite ' 1 = Prompt To Overwrite Required
UZDCL.fQuiet = uQuiet ' 2 = No Messages 1 = Less 0 = All
UZDCL.ncflag = uWriteStdOut ' 1 = Write To Stdout
UZDCL.ntflag = uTestZip ' 1 = Test Zip File
UZDCL.nvflag = uExtractList ' 0 = Extract 1 = List Contents
UZDCL.nfflag = uFreshenExisting ' 1 = Update Existing by Newer
UZDCL.nzflag = uDisplayComment ' 1 = Display Zip File Comment
UZDCL.ndflag = uHonorDirectories ' 1 = Honour Directories
UZDCL.noflag = uOverWriteFiles ' 1 = Overwrite Files
UZDCL.naflag = uConvertCR_CRLF ' 1 = Convert CR To CRLF
UZDCL.nZIflag = uVerbose ' 1 = Zip Info Verbose
UZDCL.C_flag = uCaseSensitivity ' 1 = Case insensitivity, 0 = Case Sensitivity
UZDCL.fPrivilege = uPrivilege ' 1 = ACL 2 = Priv
UZDCL.Zip = uZipFileName ' ZIP Filename
UZDCL.ExtractDir = uExtractDir ' Extraction Directory, NULL If Extracting
' To Current Directory
 
'-- Set Callback Addresses
'-- (WARNING!!!) Do Not Change
UZUSER.UZDLLPrnt = FnPtr(AddressOf UZDLLPrnt)
UZUSER.UZDLLSND = 0& '-- Not Supported
UZUSER.UZDLLREPLACE = FnPtr(AddressOf UZDLLReplacePrmt)
UZUSER.UZDLLPASSWORD = FnPtr(AddressOf UZDLLPass)
UZUSER.UZDLLMESSAGE_I32 = FnPtr(AddressOf UZReceiveDLLMessage_I32)
UZUSER.UZDLLSERVICE_I32 = FnPtr(AddressOf UZDLLServ_I32)
 
'-- Set UNZIP32.DLL Version Space
'-- (WARNING!!!) Do Not Change
With UZVER2
.structlen = Len(UZVER2)
.beta = String$(10, vbNullChar)
.date = String$(20, vbNullChar)
.zlib = String$(10, vbNullChar)
End With
 
'-- Get Version
retcode = UzpVersion2(UZVER2)
If retcode <> 0 Then
MsgBox "Incompatible DLL version discovered!" & vbNewLine _
& "The UnZip DLL requires a version structure of length " _
& CStr(retcode) & ", but the VB frontend expects the DLL to need " _
& Len(UZVER2) & "bytes." & vbNewLine _
& vbNewLine & "The program cannot continue." _
, vbCritical + vbOKOnly, App.Title
Exit Sub
End If
 
' Check that the DLL version is sufficiently recent
If (ConcatVersNums(UZVER2.unzip(1), UZVER2.unzip(2) _
, UZVER2.unzip(3), UZVER2.unzip(4)) < _
ConcatVersNums(cUzDLL_MinVer_Major, cUzDLL_MinVer_Minor _
, cUzDLL_MinVer_Revis, 0)) Then
' The found UnZip DLL is too old!
MsgBox "Incompatible old DLL version discovered!" & vbNewLine _
& "This program requires an UnZip DLL version of at least " _
& VersNumsToTxt(cUzDLL_MinVer_Major, cUzDLL_MinVer_Minor, cUzDLL_MinVer_Revis) _
& ", but the version reported by the found DLL is only " _
& VersNumsToTxt(UZVER2.unzip(1), UZVER2.unzip(2), UZVER2.unzip(3)) _
& "." & vbNewLine _
& vbNewLine & "The program cannot continue." _
, vbCritical + vbOKOnly, App.Title
Exit Sub
End If
 
' Concatenate the DLL API version info into a single version id variable.
' This variable may be used later on to switch between different
' known variants of specific API calls or API structures.
m_UzDllApiVers = ConcatVersNums(UZVER2.dllapimin(1), UZVER2.dllapimin(2) _
, UZVER2.dllapimin(3), UZVER2.dllapimin(4))
' check that the DLL API version is not too new
If (m_UzDllApiVers > _
ConcatVersNums(cUzDLL_MaxAPI_Major, cUzDLL_MaxAPI_Minor _
, cUzDLL_MaxAPI_Revis, 0)) Then
' The found UnZip DLL is too new!
MsgBox "DLL version with incompatible API discovered!" & vbNewLine _
& "This program can only handle UnZip DLL API versions up to " _
& VersNumsToTxt(cUzDLL_MaxAPI_Major, cUzDLL_MaxAPI_Minor, cUzDLL_MaxAPI_Revis) _
& ", but the found DLL reports a newer API version of " _
& VersIDToTxt(m_UzDllApiVers) & "." & vbNewLine _
& vbNewLine & "The program cannot continue." _
, vbCritical + vbOKOnly, App.Title
Exit Sub
End If
 
'--------------------------------------
'-- You Can Change This For Displaying
'-- The Version Information!
'--------------------------------------
MsgStr$ = "DLL Date: " & szTrim(UZVER2.date)
MsgStr$ = MsgStr$ & vbNewLine$ & "Zip Info: " _
& VersNumsToTxt(UZVER2.zipinfo(1), UZVER2.zipinfo(2), UZVER2.zipinfo(3))
MsgStr$ = MsgStr$ & vbNewLine$ & "DLL Version: " _
& VersNumsToTxt(UZVER2.windll(1), UZVER2.windll(2), UZVER2.windll(3))
MsgStr$ = MsgStr$ & vbNewLine$ & "DLL API Compatibility: " _
& VersIDToTxt(m_UzDllApiVers)
MsgStr$ = MsgStr$ & vbNewLine$ & "--------------"
'-- End Of Version Information.
 
'-- Go UnZip The Files! (Do Not Change Below!!!)
'-- This Is The Actual UnZip Routine
retcode = Wiz_SingleEntryUnzip(uNumberFiles, uZipNames, uNumberXFiles, _
uExcludeNames, UZDCL, UZUSER)
'---------------------------------------------------------------
 
'-- If There Is An Error Display A MsgBox!
If retcode <> 0 Then _
MsgBox "UnZip DLL call returned error code #" & CStr(retcode) _
, vbExclamation, App.Title
 
'-- Add up 64-bit values
TotalSizeComp = CnvI64Struct2Dbl(UZUSER.TotalSizeComp_Lo, _
UZUSER.TotalSizeComp_Hi)
TotalSize = CnvI64Struct2Dbl(UZUSER.TotalSize_Lo, _
UZUSER.TotalSize_Hi)
NumMembers = CnvI64Struct2Dbl(UZUSER.NumMembers_Lo, _
UZUSER.NumMembers_Hi)
 
'-- You Can Change This As Needed!
'-- For Compression Information
MsgStr$ = MsgStr$ & vbNewLine & _
"Only Shows If uExtractList = 1 List Contents"
MsgStr$ = MsgStr$ & vbNewLine & "--------------"
MsgStr$ = MsgStr$ & vbNewLine & "Comment : " & UZUSER.cchComment
MsgStr$ = MsgStr$ & vbNewLine & "Total Size Comp : " _
& Format$(TotalSizeComp, "#,0")
MsgStr$ = MsgStr$ & vbNewLine & "Total Size : " _
& Format$(TotalSize, "#,0")
MsgStr$ = MsgStr$ & vbNewLine & "Compress Factor : %" & UZUSER.CompFactor
MsgStr$ = MsgStr$ & vbNewLine & "Num Of Members : " & NumMembers
MsgStr$ = MsgStr$ & vbNewLine & "--------------"
 
VBUnzFrm.txtMsgOut.Text = VBUnzFrm.txtMsgOut.Text & MsgStr$ & vbNewLine
End Sub
/programs/fs/unzip60/windll/vb/vbunzip.frm
0,0 → 1,384
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
Begin VB.Form VBUnzFrm
AutoRedraw = -1 'True
Caption = "VBUnzFrm"
ClientHeight = 4785
ClientLeft = 780
ClientTop = 525
ClientWidth = 9375
BeginProperty Font
Name = "Fixedsys"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "VBUnzFrm"
ScaleHeight = 4785
ScaleWidth = 9375
StartUpPosition = 1 'Fenstermitte
Begin VB.CheckBox checkOverwriteAll
Alignment = 1 'Rechts ausgerichtet
Caption = "Overwrite all?"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 5
Top = 1320
Width = 4425
End
Begin VB.TextBox txtZipFName
BeginProperty Font
Name = "Courier New"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4440
TabIndex = 1
Top = 120
Width = 4335
End
Begin VB.TextBox txtExtractRoot
BeginProperty Font
Name = "Courier New"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4440
TabIndex = 4
Top = 720
Width = 4335
End
Begin VB.CommandButton cmdStartUnz
Caption = "Start"
Height = 495
Left = 240
TabIndex = 6
Top = 1800
Width = 3255
End
Begin VB.TextBox txtMsgOut
BeginProperty Font
Name = "Courier New"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2175
Left = 240
Locked = -1 'True
MultiLine = -1 'True
ScrollBars = 3 'Beides
TabIndex = 8
TabStop = 0 'False
Top = 2520
Width = 8895
End
Begin VB.CommandButton cmdQuitVBUnz
Cancel = -1 'True
Caption = "Quit"
Height = 495
Left = 6240
TabIndex = 7
Top = 1800
Width = 2895
End
Begin VB.CommandButton cmdSearchZfile
Caption = "..."
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 8760
TabIndex = 2
Top = 120
Width = 375
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 4800
Top = 1800
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.Label Label1
Caption = "Complete path-name of Zip-archive:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 0
Top = 120
Width = 3855
End
Begin VB.Label Label2
Caption = "Extract archive into directory:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 3
Top = 720
Width = 3855
End
End
Attribute VB_Name = "VBUnzFrm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
 
'---------------------------------------------------
'-- Please Do Not Remove These Comment Lines!
'----------------------------------------------------------------
'-- Sample VB 5 / VB 6 code to drive unzip32.dll
'-- Contributed to the Info-ZIP project by Mike Le Voi
'--
'-- Contact me at: mlevoi@modemss.brisnet.org.au
'--
'-- Visit my home page at: http://modemss.brisnet.org.au/~mlevoi
'--
'-- Use this code at your own risk. Nothing implied or warranted
'-- to work on your machine :-)
'----------------------------------------------------------------
'--
'-- This Source Code Is Freely Available From The Info-ZIP Project
'-- Web Server At:
'-- ftp://ftp.info-zip.org/pub/infozip/infozip.html
'--
'-- A Very Special Thanks To Mr. Mike Le Voi
'-- And Mr. Mike White
'-- And The Fine People Of The Info-ZIP Group
'-- For Letting Me Use And Modify Their Orginal
'-- Visual Basic 5.0 Code! Thank You Mike Le Voi.
'-- For Your Hard Work In Helping Me Get This To Work!!!
'---------------------------------------------------------------
'--
'-- Contributed To The Info-ZIP Project By Raymond L. King.
'-- Modified June 21, 1998
'-- By Raymond L. King
'-- Custom Software Designers
'--
'-- Contact Me At: king@ntplx.net
'-- ICQ 434355
'-- Or Visit Our Home Page At: http://www.ntplx.net/~king
'--
'---------------------------------------------------------------
'--
'-- Modified August 17, 1998
'-- by Christian Spieler
'-- (added sort of a "windows oriented" user interface)
'-- Modified May 11, 2003
'-- by Christian Spieler
'-- (use late binding for referencing the common dialog)
'-- Modified December 30, 2008
'-- by Ed Gordon
'-- (add Overwrite_All checkbox and resizing of txtMsgOut
'-- output box)
'-- Modified January 03, 2009
'-- by Christian Spieler
'-- (fixed tab navigation sequence, changed passing of
'-- "overwrite-all" setting to use existing option flags,
'-- cleared all msg buffer at start of every DLL call,
'-- removed code that is not supported by VB5)
'--
'---------------------------------------------------------------
 
Private mCommDlgCtrl As Object
 
Private Sub cmdStartUnz_Click()
 
Dim MsgTmp As String
Cls
txtMsgOut.Text = ""
'-- Init Global Message Variables
uZipInfo = ""
uZipMessage = ""
uZipNumber = 0 ' Holds The Number Of Zip Files
'-- Select UNZIP32.DLL Options - Change As Required!
' 1 = Always Overwrite Files
uOverWriteFiles = Me.checkOverwriteAll.Value
' 1 = Prompt To Overwrite
uPromptOverWrite = IIf(uOverWriteFiles = 0, 1, 0)
uDisplayComment = 0 ' 1 = Display comment ONLY!!!
uHonorDirectories = 1 ' 1 = Honour Zip Directories
'-- Select Filenames If Required
'-- Or Just Select All Files
uZipNames.uzFiles(0) = vbNullString
uNumberFiles = 0
'-- Select Filenames To Exclude From Processing
' Note UNIX convention!
' vbxnames.s(0) = "VBSYX/VBSYX.MID"
' vbxnames.s(1) = "VBSYX/VBSYX.SYX"
' numx = 2
'-- Or Just Select All Files
uExcludeNames.uzFiles(0) = vbNullString
uNumberXFiles = 0
'-- Change The Next 2 Lines As Required!
'-- These Should Point To Your Directory
uZipFileName = txtZipFName.Text
uExtractDir = txtExtractRoot.Text
If Len(uExtractDir) <> 0 Then
uExtractList = 0 ' 0 = Extract if dir specified
Else
uExtractList = 1 ' 1 = List Contents Of Zip
End If
'-- Let's Go And Unzip Them!
Call VBUnZip32
'-- Tell The User What Happened
If Len(uZipMessage) > 0 Then
MsgTmp = uZipMessage
uZipMessage = ""
End If
'-- Display Zip File Information.
If Len(uZipInfo) > 0 Then
MsgTmp = MsgTmp & vbNewLine & "uZipInfo is:" & vbNewLine & uZipInfo
uZipInfo = ""
End If
'-- Display The Number Of Extracted Files!
If uZipNumber > 0 Then
MsgTmp = MsgTmp & vbNewLine & "Number Of Files: " & Str(uZipNumber)
End If
txtMsgOut.Text = txtMsgOut.Text & MsgTmp & vbNewLine
End Sub
 
 
Private Sub Form_Load()
'-- To work around compatibility issues between different versions of
'-- Visual Basic, we use a late bound untyped object variable to reference
'-- the common dialog ActiveX-control object at runtime.
On Error Resume Next
Set mCommDlgCtrl = CommonDialog1
On Error GoTo 0
'-- Disable the "call openfile dialog" button, when the common dialog
'-- object is not available
cmdSearchZfile.Visible = Not (mCommDlgCtrl Is Nothing)
txtZipFName.Text = vbNullString
txtExtractRoot.Text = vbNullString
Me.Show
End Sub
 
Private Sub Form_Resize()
Dim Wid As Single
Dim Hei As Single
Wid = Me.Width - 600 ' 9495 - 8895
If Wid < 2000 Then Wid = 2000
txtMsgOut.Width = Wid
Hei = Me.Height - 3120 ' 5295 - 2175
If Hei < 1000 Then Hei = 1000
txtMsgOut.Height = Hei
 
End Sub
 
Private Sub Form_Unload(Cancel As Integer)
'-- remove runtime reference to common dialog control object
Set mCommDlgCtrl = Nothing
End Sub
 
 
Private Sub cmdQuitVBUnz_Click()
Unload Me
End Sub
 
 
Private Sub cmdSearchZfile_Click()
If mCommDlgCtrl Is Nothing Then Exit Sub
mCommDlgCtrl.CancelError = False
mCommDlgCtrl.DialogTitle = "Open Zip-archive"
'-- The following property is not supported in the first version(s)
'-- of the common dialog controls. But this feature is of minor
'-- relevance in our context, so we simply skip over the statement
'-- in case of errors.
On Error Resume Next
mCommDlgCtrl.DefaultExt = ".zip"
On Error GoTo err_deactivateControl
'-- Initialize the file name with the current setting of the filename
'-- text box.
mCommDlgCtrl.FileName = txtZipFName.Text
'-- Provide reasonable filter settings for selecting Zip archives.
mCommDlgCtrl.Filter = "Zip archives (*.zip)|*.zip|All files (*.*)|*.*"
mCommDlgCtrl.ShowOpen
'-- In case the user closed the dialog via cancel, the FilenName
'-- property contains its initial setting and no change occurs.
txtZipFName.Text = mCommDlgCtrl.FileName
Exit Sub
 
err_deactivateControl:
'-- Emit a warning message.
MsgBox "Unexpected error #" & CStr(Err.Number) & " in call to ComDLG32" _
& " FileOpen dialog:" & vbNewLine & Err.Description & vbNewLine _
& vbNewLine & "The version of the COMDLG32.OCX control installed" _
& " on your system seems to be too old. Please consider upgrading" _
& " to a recent release of the Common Dialog ActiveX control." _
& vbNewLine & "The ""Choose File from List"" dialog functionality" _
& " has been disabled for this session.", _
vbCritical + vbOKOnly, "FileOpen Dialog incompatible"
'-- Deactivate the control and prevent further usage in this session.
Set mCommDlgCtrl = Nothing
cmdSearchZfile.Enabled = False
End Sub
 
/programs/fs/unzip60/windll/vb/vbunzip.vbp
0,0 → 1,34
Type=Exe
Form=vbunzip.frm
Module=VBUnzBas; vbunzip.bas
Object={F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0; COMDLG32.OCX
IconForm="VBUnzFrm"
Startup="VBUnzFrm"
HelpFile=""
Title="VBUnZip"
ExeName32="VBunzip.exe"
Command32=""
Name="VBUnzipProject"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionCompanyName="Info-ZIP"
VersionLegalCopyright="(c) Info-ZIP 1998-2009"
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
ThreadPerObject=0
MaxNumberOfThreads=1