获取文件属性中详细信息里的各项目(vb 学习备注)

获取文件属性中详细信息里的各项目(vb 学习备注),第1张

概述Sub ts() Dim oDLG Dim pth As String Dim Flname As String Dim shl As Shell32.Shell Dim shfd As Shell32.Folder Dim s As String Dim i As Integer Set oDLG = Crea
Sub ts()    Dim oDLG    Dim pth As String    Dim Flname As String        Dim shl As Shell32.Shell    Dim shfd As Shell32.Folder    Dim s As String    Dim i As Integer        Set oDLG = CreateObject("MSComDlg.CommonDialog")        With oDLG                        .DialogTitle = "打开文件"            .Filter = "所有文件|*.*"            .MaxfileSize = 255            .ShowOpen            If .filename <> "" Then                                i = InStrRev(.filename,"\")                If i = 0 Then Exit Sub                Flname = MID(.filename,i + 1)                Set shl = New Shell                Set shfd = shl.namespace(left(.filename,i - 1))            For i = 0 To 39                            If shfd.GetDetailsOf(0,i) <> "" And shfd.GetDetailsOf(shfd.Items.Item(Flname),i) <> "" Then                                        s = s & i & ":" & shfd.GetDetailsOf(0,i) & ": " & shfd.GetDetailsOf(shfd.Items.Item(Flname),i) & Chr(10)                    DeBUG.Print s                                    End If                            Next i                        MsgBox s,vbinformation,"文件属性"                    End If            End With        Set oDLG = nothing    End Sub

先引用Microsoft Shell Controls and automation



VBA实例

Sub ts()    Dim pth As String    Dim Flname As String    Dim sPath As String    Dim sOwner As String        Dim shl As Shell32.Shell    Dim shfd As Shell32.Folder    Dim s As String    Dim i As Integer        sPath = "\10.116.0.26\smc82files、公用文件\"    Flname = Dir(sPath)        i = 2        do while Flname <> ""            If Flname <> "." And Flname <> ".." Then                If GetAttr(sPath & Flname) = vbDirectory Then                            Flname = Dir()                            Else                            Set shl = New Shell                Set shfd = shl.namespace(sPath)                ActiveSheet.Cells(i,1).Value = Flname                ActiveSheet.Cells(i,2).Value = shfd.GetDetailsOf(shfd.Items.Item(Flname),10)                ActiveSheet.Cells(i,3).Value = shfd.GetDetailsOf(shfd.Items.Item(Flname),20)                i = i + 1                Flname = Dir()                            End If                    Else                    Flname = Dir()                    End If                Loop        MsgBox "ok"                End Sub
总结

以上是内存溢出为你收集整理的获取文件属性详细信息里的各项目(vb 学习备注)全部内容,希望文章能够帮你解决获取文件属性中详细信息里的各项目(vb 学习备注)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1281535.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存