⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vbunzip.bas

📁 完整的解压zip文件的源码。包含密码功能
💻 BAS
📖 第 1 页 / 共 2 页
字号:
'-- Callback For UNZIP32.DLL - Print Message FunctionPublic Function UZDLLPrnt(ByRef fname As UNZIPCBChar, ByVal x As Long) As Long  Dim s0 As String  Dim xx As Long  '-- Always Put This In Callback Routines!  On Error Resume Next  s0 = ""  '-- Gets The UNZIP32.DLL Message For Displaying.  For xx = 0 To x - 1    If fname.ch(xx) = 0 Then Exit For    s0 = s0 & Chr(fname.ch(xx))  Next  '-- Assign Zip Information  If Mid$(s0, 1, 1) = vbLf Then s0 = vbNewLine ' Damn UNIX :-)  uZipInfo = uZipInfo & s0  UZDLLPrnt = 0End Function'-- Callback For UNZIP32.DLL - DLL Service FunctionPublic Function UZDLLServ(ByRef mname As UNZIPCBChar, ByVal x As Long) As Long    Dim s0 As String    Dim xx As Long        '-- Always Put This In Callback Routines!    On Error Resume Next        s0 = ""    '-- Get Zip32.DLL Message For processing    For xx = 0 To x - 1        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    ' It is up to the developer to code something useful here :)    UZDLLServ = 0 ' Setting this to 1 will abort the zip!End Function'-- Callback For UNZIP32.DLL - Password FunctionPublic Function UZDLLPass(ByRef p As UNZIPCBCh, _  ByVal n As Long, ByRef m As UNZIPCBCh, _  ByRef Name As UNZIPCBCh) As Integer  Dim prompt     As String  Dim xx         As Integer  Dim szpassword As String  '-- Always Put This In Callback Routines!  On Error Resume Next  UZDLLPass = 1  If uVbSkip = 1 Then Exit Function  '-- Get The Zip File Password  szpassword = InputBox("Please Enter The Password!")  '-- No Password So Exit The Function  If szpassword = "" Then    uVbSkip = 1    Exit Function  End If  '-- Zip File Password So Process It  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) ' Put Null Terminator For C  UZDLLPass = 0End 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 UZDLLRep(ByRef fname As UNZIPCBChar) As Long  Dim s0 As String  Dim xx As Long  '-- Always Put This In Callback Routines!  On Error Resume Next  UZDLLRep = 100 ' 100 = Do Not Overwrite - Keep Asking User  s0 = ""  For xx = 0 To 255    If fname.ch(xx) = 0 Then xx = 99999 Else s0 = s0 & Chr(fname.ch(xx))  Next  '-- This Is The MsgBox Code  xx = MsgBox("Overwrite " & s0 & "?", vbExclamation & vbYesNoCancel, _              "VBUnZip32 - File Already Exists!")  If xx = vbNo Then Exit Function  If xx = vbCancel Then    UZDLLRep = 104       ' 104 = Overwrite None    Exit Function  End If  UZDLLRep = 102         ' 102 = Overwrite 103 = Overwrite AllEnd Function'-- ASCIIZ To String FunctionPublic Function szTrim(szString As String) As String  Dim pos As Integer  Dim ln  As Integer  pos = InStr(szString, Chr(0))  ln = Len(szString)  Select Case pos    Case Is > 1      szTrim = Trim(Left(szString, pos - 1))    Case 1      szTrim = ""    Case Else      szTrim = Trim(szString)  End SelectEnd Function'-- Main UNZIP32.DLL UnZip32 Subroutine'-- (WARNING!) Do Not Change!Public Sub VBUnZip32()  Dim retcode As Long  Dim MsgStr As String  '-- Set The UNZIP32.DLL Options  '-- (WARNING!) Do Not Change  UZDCL.ExtractOnlyNewer = uExtractNewer     ' 1 = Extract Only Newer  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.nUflag = uExtractOnlyNewer           ' 1 = Extract Only 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 UZDLLRep)  UZUSER.UZDLLPASSWORD = FnPtr(AddressOf UZDLLPass)  UZUSER.UZDLLMESSAGE = FnPtr(AddressOf UZReceiveDLLMessage)  UZUSER.UZDLLSERVICE = FnPtr(AddressOf UZDLLServ)  '-- Set UNZIP32.DLL Version Space  '-- (WARNING!!!) Do Not Change  With UZVER    .structlen = Len(UZVER)    .beta = Space(9) & vbNullChar    .date = Space(19) & vbNullChar    .zlib = Space(9) & vbNullChar  End With  '-- Get Version  Call UzpVersion2(UZVER)  '--------------------------------------  '-- You Can Change This For Displaying  '-- The Version Information!  '--------------------------------------  MsgStr$ = "DLL Date: " & szTrim(UZVER.date)  MsgStr$ = MsgStr$ & vbNewLine$ & "Zip Info: " & Hex(UZVER.zipinfo(1)) & "." & _       Hex(UZVER.zipinfo(2)) & Hex(UZVER.zipinfo(3))  MsgStr$ = MsgStr$ & vbNewLine$ & "DLL Version: " & Hex(UZVER.windll(1)) & "." & _       Hex(UZVER.windll(2)) & Hex(UZVER.windll(3))  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 retcode  '-- 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 : " & UZUSER.TotalSizeComp  MsgStr$ = MsgStr$ & vbNewLine$ & "Total Size      : " & UZUSER.TotalSize  MsgStr$ = MsgStr$ & vbNewLine$ & "Compress Factor : %" & UZUSER.CompFactor  MsgStr$ = MsgStr$ & vbNewLine$ & "Num Of Members  : " & UZUSER.NumMembers  MsgStr$ = MsgStr$ & vbNewLine$ & "--------------"  VBUnzFrm.MsgOut.Text = VBUnzFrm.MsgOut.Text & MsgStr$ & vbNewLine$End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -