Geez Elroy. If you're going to get that complex you might as well show a FULL display...
Actually I take that back, as doing this is less complex :P
[VB6, Vista+] List all file properties, locale/unit formatted, by modern PROPERTYKEY
Edit: If you just want to look up individual properties,
(with oleexp.tlb/mIID.bas present)Code:Public Declare Function PSGetPropertyKeyFromName Lib "propsys.dll" (ByVal pszName As Long, ppropkey As PROPERTYKEY) As Long Public Declare Function PSFormatPropertyValue Lib "propsys.dll" (ByVal pps As Long, ByVal ppd As Long, ByVal pdff As PROPDESC_FORMAT_FLAGS, ppszDisplay As Long) As Long Public Declare Function SHGetPropertyStoreFromParsingName Lib "shell32" (ByVal pszPath As Long, pbc As Any, ByVal Flags As GETPROPERTYSTOREFLAGS, riid As UUID, ppv As Any) As Long Public Declare Function PSGetPropertyDescription Lib "propsys.dll" (PropKey As PROPERTYKEY, riid As UUID, ppv As Any) As Long Public Declare Function SysReAllocString Lib "oleaut32.dll" (ByVal pBSTR As Long, Optional ByVal pszStrPtr As Long) As Long Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal PV As Long) ' Frees memory allocated by the shell Public Function GetPropertyDisplayString(szFile As String, szProp As String) As String 'Gets the string value of the given canonical property; e.g. System.Company, System.Rating, etc 'This would be the value displayed in Explorer if you added the column in details view Dim pkProp As PROPERTYKEY Dim pps As IPropertyStore Dim lpsz As Long Dim ppd As IPropertyDescription PSGetPropertyKeyFromName StrPtr(szProp), pkProp SHGetPropertyStoreFromParsingName StrPtr(szFile), ByVal 0&, GPS_DEFAULT Or GPS_BESTEFFORT Or GPS_OPENSLOWITEM, IID_IPropertyStore, pps PSGetPropertyDescription pkProp, IID_IPropertyDescription, ppd PSFormatPropertyValue ObjPtr(pps), ObjPtr(ppd), PDFF_DEFAULT, lpsz SysReAllocString VarPtr(GetPropertyDisplayString), lpsz CoTaskMemFree lpsz End Function
You use that function with the property name, e.g. szSize = GetPropertyDisplayString("C:\myfile.jpg", "System.Size") and it would return "100 KB" or whatever the size was, already formatted like Explorer. See: [VB6, Vista+] A compact function to retrieve any property by name, locally formatted





Reply With Quote
