123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458 |
- Attribute VB_Name = "VBZipBas"
- Option Explicit
- Public Type ZIPnames
- zFiles(0 To 99) As String
- End Type
- Public Type ZipCBChar
- ch(4096) As Byte
- End Type
- Public Type ZPOPT
- Date As String
- szRootDir As String
- szTempDir As String
- fTemp As Long
- fSuffix As Long
- fEncrypt As Long
- fSystem As Long
- fVolume As Long
- fExtra As Long
- fNoDirEntries As Long
- fExcludeDate As Long
- fIncludeDate As Long
- fVerbose As Long
- fQuiet As Long
- fCRLF_LF As Long
- fLF_CRLF As Long
- fJunkDir As Long
- fGrow As Long
- fForce As Long
- fMove As Long
- fDeleteEntries As Long
- fUpdate As Long
- fFreshen As Long
- fJunkSFX As Long
- fLatestTime As Long
- fComment As Long
- fOffsets As Long
- fPrivilege As Long
- fEncryption As Long
- fRecurse As Long
- fRepair As Long
- flevel As Byte
- End Type
- Public Type ZIPUSERFUNCTIONS
- ZDLLPrnt As Long
- ZDLLCOMMENT As Long
- ZDLLPASSWORD As Long
- ZDLLSERVICE As Long
- End Type
- Public ZOPT As ZPOPT
- Public ZUSER As ZIPUSERFUNCTIONS
- Private Declare Function ZpInit Lib "zip32.dll" _
- (ByRef Zipfun As ZIPUSERFUNCTIONS) As Long
- Private Declare Function ZpSetOptions Lib "zip32.dll" _
- (ByRef Opts As ZPOPT) As Long
- Private Declare Function ZpGetOptions Lib "zip32.dll" _
- () As ZPOPT
- Private Declare Function ZpArchive Lib "zip32.dll" _
- (ByVal argc As Long, ByVal funame As String, _
- ByRef argv As ZIPnames) As Long
- Public zDate As String
- Public zRootDir As String
- Public zTempDir As String
- Public zSuffix As Integer
- Public zEncrypt As Integer
- Public zSystem As Integer
- Public zVolume As Integer
- Public zExtra As Integer
- Public zNoDirEntries As Integer
- Public zExcludeDate As Integer
- Public zIncludeDate As Integer
- Public zVerbose As Integer
- Public zQuiet As Integer
- Public zCRLF_LF As Integer
- Public zLF_CRLF As Integer
- Public zJunkDir As Integer
- Public zRecurse As Integer
- Public zGrow As Integer
- Public zForce As Integer
- Public zMove As Integer
- Public zDelEntries As Integer
- Public zUpdate As Integer
- Public zFreshen As Integer
- Public zJunkSFX As Integer
- Public zLatestTime As Integer
- Public zComment As Integer
- Public zOffsets As Integer
- Public zPrivilege As Integer
- Public zEncryption As Integer
- Public zRepair As Integer
- Public zLevel As Integer
- Public zArgc As Integer
- Public zZipFileName As String
- Public zZipFileNames As ZIPnames
- Public zZipInfo As String
- Public Const ZE_OK = 0
- Public Const ZE_EOF = 2
- Public Const ZE_FORM = 3
- Public Const ZE_MEM = 4
- Public Const ZE_LOGIC = 5
- Public Const ZE_BIG = 6
- Public Const ZE_NOTE = 7
- Public Const ZE_TEST = 8
- Public Const ZE_ABORT = 9
- Public Const ZE_TEMP = 10
- Public Const ZE_READ = 11
- Public Const ZE_NONE = 12
- Public Const ZE_NAME = 13
- Public Const ZE_WRITE = 14
- Public Const ZE_CREAT = 15
- Public Const ZE_PARMS = 16
- Public Const ZE_OPEN = 18
- Public Function FnPtr(ByVal lp As Long) As Long
-
- FnPtr = lp
- End Function
- Public Function ZDLLPrnt(ByRef fname As ZipCBChar, ByVal x As Long) As Long
-
- Dim s0 As String
- Dim xx As Long
-
-
- On Error Resume Next
-
- s0 = ""
-
-
- For xx = 0 To x
- If fname.ch(xx) = 0 Then
- Exit For
- Else
- s0 = s0 + Chr(fname.ch(xx))
- End If
- Next
-
-
-
-
-
-
-
-
-
- Form1.Print s0;
-
- DoEvents
-
- ZDLLPrnt = 0
- End Function
- Public Function ZDLLServ(ByRef mname As ZipCBChar, ByVal x As Long) As Long
-
-
- Dim s0 As String
- Dim xx As Long
-
-
- On Error Resume Next
-
- s0 = ""
-
- For xx = 0 To 4096
- If mname.ch(xx) = 0 Then
- Exit For
- Else
- s0 = s0 + Chr(mname.ch(xx))
- End If
- Next
-
-
-
-
-
-
-
- ZDLLServ = 0
-
- End Function
- Public Function ZDLLPass(ByRef p As ZipCBChar, _
- ByVal n As Long, ByRef m As ZipCBChar, _
- ByRef Name As ZipCBChar) As Integer
-
- Dim prompt As String
- Dim xx As Integer
- Dim szpassword As String
-
-
- On Error Resume Next
-
- ZDLLPass = 1
-
-
-
- szpassword = InputBox("Please Enter The Password!")
-
-
- If szpassword = "" Then Exit Function
-
-
- For xx = 0 To 255
- If m.ch(xx) = 0 Then
- Exit For
- Else
- prompt = prompt & Chr(m.ch(xx))
- End If
- Next
-
- For xx = 0 To n - 1
- p.ch(xx) = 0
- Next
-
- For xx = 0 To Len(szpassword) - 1
- p.ch(xx) = Asc(Mid(szpassword, xx + 1, 1))
- Next
-
- p.ch(xx) = Chr(0)
-
- ZDLLPass = 0
-
- End Function
- Public Function ZDLLComm(ByRef s1 As ZipCBChar) As Integer
-
- Dim xx%, szcomment$
-
-
- On Error Resume Next
-
- ZDLLComm = 1
- szcomment = InputBox("Enter the comment")
- If szcomment = "" Then Exit Function
- For xx = 0 To Len(szcomment) - 1
- s1.ch(xx) = Asc(Mid$(szcomment, xx + 1, 1))
- Next xx
- s1.ch(xx) = Chr(0)
- End Function
- Public Function VBZip32() As Long
-
- Dim retcode As Long
-
- On Error Resume Next
-
- retcode = 0
-
-
-
- ZUSER.ZDLLPrnt = FnPtr(AddressOf ZDLLPrnt)
- ZUSER.ZDLLPASSWORD = FnPtr(AddressOf ZDLLPass)
- ZUSER.ZDLLCOMMENT = FnPtr(AddressOf ZDLLComm)
- ZUSER.ZDLLSERVICE = FnPtr(AddressOf ZDLLServ)
-
-
- retcode = ZpInit(ZUSER)
- If retcode = 0 Then
- MsgBox "Zip32.dll did not initialize. Is it in the current directory " & _
- "or on the command path?", vbOKOnly, "VB Zip"
- Exit Function
- End If
-
-
-
- ZOPT.Date = zDate
- ZOPT.szRootDir = zRootDir
- ZOPT.szTempDir = zTempDir
- ZOPT.fSuffix = zSuffix
- ZOPT.fEncrypt = zEncrypt
- ZOPT.fSystem = zSystem
- ZOPT.fVolume = zVolume
- ZOPT.fExtra = zExtra
- ZOPT.fNoDirEntries = zNoDirEntries
- ZOPT.fExcludeDate = zExcludeDate
- ZOPT.fIncludeDate = zIncludeDate
- ZOPT.fVerbose = zVerbose
- ZOPT.fQuiet = zQuiet
- ZOPT.fCRLF_LF = zCRLF_LF
- ZOPT.fLF_CRLF = zLF_CRLF
- ZOPT.fJunkDir = zJunkDir
- ZOPT.fGrow = zGrow
- ZOPT.fForce = zForce
- ZOPT.fMove = zMove
- ZOPT.fDeleteEntries = zDelEntries
- ZOPT.fUpdate = zUpdate
- ZOPT.fFreshen = zFreshen
- ZOPT.fJunkSFX = zJunkSFX
- ZOPT.fLatestTime = zLatestTime
- ZOPT.fComment = zComment
- ZOPT.fOffsets = zOffsets
- ZOPT.fPrivilege = zPrivilege
- ZOPT.fEncryption = zEncryption
- ZOPT.fRecurse = zRecurse
- ZOPT.fRepair = zRepair
- ZOPT.flevel = zLevel
-
-
- retcode = ZpSetOptions(ZOPT)
-
-
- retcode = ZpArchive(zArgc, zZipFileName, zZipFileNames)
-
-
- VBZip32 = retcode
- End Function
|