by kAOs (9 Submissions)
Category: Windows System Services
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 9th June 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Obtain properties of a file.
Dim Shell As New Shell
Private Sub Form_Load()
MsgBox GetDetailsOf("C:\a.txt", "Comments")
End Sub
Function GetDetailsOf(FileName As String, FieldName As String) As String
'Get the folder object
Dim Folder As Folder
Set Folder = Shell.NameSpace(Left$(FileName, InStrRev(FileName, "\") - 1))
Dim N As Integer
For N = 1 To 25 'Search the field name
If Folder.GetDetailsOf(Nothing, N) = FieldName Then
'If field name matches, get the field value
GetDetailsOf = Folder.GetDetailsOf(Folder.ParseName(Dir$(FileName)), N)
Exit Function
End If
Next
End Function