|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
不使用压缩DLL在内的压缩工具,以下程序可以枚举ZIP文件中的文件信息。
Option Explicit
Private mintCnt As Integer
Private Function IsFolder(ByVal SrcPath As String) As Boolean
IsFolder = CreateObject("Scripting.FileSystemObject").FolderExists(SrcPath)
End Function
Sub sListZipFile()
psListZipFile "F:\Demo.zip"
End Sub
Sub psListZipFile(ByVal ivrtSPath As Variant, Optional ByVal ivrtTPath As Variant = "")
Dim pobjSrc As Object
Dim pbytTmp As Byte
With CreateObject("Scripting.FileSystemObject")
If .FileExists(ivrtSPath) = False Then Exit Sub
If LCase(.GetExtensionName(ivrtSPath)) <> "zip" Then Exit Sub
If IsFolder(ivrtTPath) = False Then ivrtTPath = .GetFile(ivrtSPath).ParentFolder.Path
End With
Application.ScreenUpdating = False
With Me
.Range(.UsedRange.Address).Delete
With CreateObject("Shell.Application")
Set pobjSrc = .Namespace(ivrtSPath)
For pbytTmp = 0 To 8
DoEvents
Me.Cells(1, pbytTmp + 2) = pobjSrc.GetDetailsOf(, pbytTmp)
Next
mintCnt = 0
psReadFileInfo pobjSrc
End With
.Columns.AutoFit
End With
Application.ScreenUpdating = True
Set pobjSrc = Nothing
End Sub
Private Sub psReadFileInfo(objSrc As Object)
Dim pobjTmp As Object
Dim pbytTmp As Byte
Dim pobjTnp As Object
For Each pobjTmp In objSrc.items
DoEvents
If pobjTmp.IsFolder Then
Set pobjTnp = pobjTmp.GetFolder
psReadFileInfo pobjTnp
Set pobjTnp = Nothing
Else
mintCnt = mintCnt + 1
Me.Cells(mintCnt + 1, 1) = mintCnt
For pbytTmp = 0 To 8
DoEvents
Me.Cells(mintCnt + 1, pbytTmp + 2) = objSrc.GetDetailsOf(pobjTmp, pbytTmp)
Next
End If
Next
Set pobjTmp = Nothing
End Sub |
|