'引用Microsoft Shell Controls And Automation
Private Sub Command1_Click()
MsgBox getfilePTY("C:\WINDOWS\notepad.exe")
End SubFunction getfilePTY(strFl As String) As String
Dim fso 'As FileSystemObject
Dim fl 'As Scripting.File
Dim pth As String
Dim flname As StringDim shl As Shell32.Shell
Dim shfd As Shell32.Folder
Dim s As String
Dim i'Set fso = New FileSystemObject
Set fso = CreateObject("scripting.filesystemobject")
Set fl = fso.GetFile(strFl)
pth = fl.ParentFolder.Path
flname = fl.NameSet shl = New Shell
Set shfd = shl.NameSpace(pth)For i = 0 To 33
  If shfd.GetDetailsOf(0, i) <> "" Or shfd.GetDetailsOf(shfd.Items.Item(flname), i) <> "" Then
     s = s & shfd.GetDetailsOf(0, i) & ":  " & shfd.GetDetailsOf(shfd.Items.Item(flname), i) & Chr(10)
  End If
Next igetfilePTY = s
End Function但是对于OFFICE文件还是有部分无法得到,不知有更好方法?

解决方案 »

  1.   

    学习。
    以下是被我改了一下的版本,好像也行。Function getfilePTY(strFl As String) As String
      Dim shl As Shell, shfd As Folder, shitem As FolderItem
      Dim i As Long, s As String, ts As String  Set shl = New Shell
      Set shfd = shl.NameSpace(strFl)
      Set shitem = shfd.ParentFolder.Items.Item(shfd.Title)
      Set shfd = shfd.ParentFolder
      i = 0&
      Do
        ts = shfd.GetDetailsOf(Null, i)
        If ts <> vbNullString Then _
          s = s & ts & vbTab & shfd.GetDetailsOf(shitem, i) & vbNewLine _
        Else Exit Do
        i = i + 1&
      Loop
      
      Set shitem = Nothing
      Set shfd = Nothing
      Set shl = Nothing
      
      getfilePTY = s
    End Function
      

  2.   

    TO:James0001(虾米—什么时候成大虾?) 
    GetDetailsOf(Null, i)是不连续的,就是说出现“空”后,后面还有。所以你的少了好几条信息。