Sub test()
Const fol As String = "C:\"
Const fil As String = "DiabloSwingOrchestra-PandorasPinata.jpg"
Debug.Print "name ", fnGetDetailsOfVB(fol, fil, GetPropByName(fol, fil, "name"))
Debug.Print "owner ", fnGetDetailsOfVB(fol, fil, GetPropByName(fol, fil, "owner"))
Debug.Print "authors ", fnGetDetailsOfVB(fol, fil, GetPropByName(fol, fil, "authors"))
Debug.Print "author ", fnGetDetailsOfVB(fol, fil, GetPropByName(fol, fil, "author"))
Debug.Print "size ", fnGetDetailsOfVB(fol, fil, GetPropByName(fol, fil, "size"))
Debug.Print "date modified", fnGetDetailsOfVB(fol, fil, GetPropByName(fol, fil, "date modified"))
Debug.Print "type ", fnGetDetailsOfVB(fol, fil, GetPropByName(fol, fil, "type"))
Debug.Print "rating ", fnGetDetailsOfVB(fol, fil, GetPropByName(fol, fil, "rating"))
Debug.Print "camera maker ", fnGetDetailsOfVB(fol, fil, GetPropByName(fol, fil, "camera maker"))
End Sub
Private Function fnGetDetailsOfVB(fpath As String, fname As String, prop As Integer) As String
'stolen from https://msdn.microsoft.com/en-us/library/windows/desktop/bb787870(v=vs.85).aspx
If prop < 0 Then
fnGetDetailsOfVB = "property not found"
Exit Function
End If
Dim objShell, objFolder, objFolderItem
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(CVar(fpath))
If (Not objFolder Is Nothing) Then
Set objFolderItem = objFolder.ParseName(fname)
If (Not objFolderItem Is Nothing) Then
fnGetDetailsOfVB = objFolder.GetDetailsOf(objFolderItem, prop)
Set objFolderItem = Nothing
End If
End If
Set objFolder = Nothing
Set objShell = Nothing
End Function
Private Function GetPropByName(fpath As String, fname As String, prop As String) As Integer
Dim objFolder
Set objFolder = CreateObject("Shell.Application").Namespace(CVar(fpath))
GetPropByName = -1
If (Not objFolder Is Nothing) Then
For i = 0 To 300 'how to check #items???
s = objFolder.GetDetailsOf(fname, i)
If StrComp(s, prop, vbTextCompare) = 0 Then
GetPropByName = i
Exit Function
End If
Next
End If
End Function