Results 1 to 7 of 7
  1. #1
    Miles R is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Mar 2019
    Posts
    280

    Using ExtendedPropery instead of GetDetailsOf to find Extended File Properties

    I have for a long time been using GetDetailsOf to extract file properties from Image Files e.g.
    strLens = objFolder.GetDetailsOf(objFolderItem, 266)
    (where 266 is the current offset value for Lens Model)

    Now, I discover an alternative method using :-


    strLens = objFolderItem.ExtendedProperty("System.Photo.LensM odel")

    Both give the same result and the latter has the advantage that it is more readable and I don't need to establish the 266 offset before use (these values do change from time to time).

    I wonder if anyone has a view on which is better - more efficient?, faster?, less likely to be de-functioned in future Windows releases?

    p.s. Don't know why a space has appeared between LensM and odel - it should read LensModel, but don't seem to be able to edit it.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Forum throws in space by design, don't remember why. Post code between CODE tags and don't think space will occur.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    I have for many years used GetDetailsOf to obtain all the extended properties for a file or group of files.
    Its fast, easy to use and obtains all the information I never need. See my free Extended File Properties app

    I wasn't aware of the ShellFolderItem.ExtendedProperty method until now and had to look it up.
    Apart from being able to specify an extended property by name or number, what do you see as its advantages over using GetDetailsOf for an individual property?

    As for speed, I expect both methods are similar. Why not test for yourself on a group of files and report back?

    Both methods are part of the Shell32 library. If support for that library were ever removed, both methods would be lost (as well as lot of other important functionality)
    I think its highly unlikely either method will disappear in the future
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  4. #4
    Miles R is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Mar 2019
    Posts
    280
    Thanks for the replies.
    It is curious about the space in the text. I did not bother about the CODE tags as it was only one line.

    On to the issue at hand however. I did run some crude benchmarks on my system. I put both methods in a loop and looped 500,000 times.
    The results were very similar :
    ExtendedProperty took 700 seconds
    GetDetailsOf took 726 seconds

    I was getting consistent slightly better performance for ExtendedProperty, but not significant. They both take about 1.4ms to execute (which I think is still pretty slow really)

    I may move to using ExtendedProperty as there is no need to look up the offsets in advance. I read somewhere that the File Explorer Right Click Properties uses this method. Not confirmed that though.

    For information, the list of text values can be found in
    System.Photo.LensModel - Win32 apps | Microsoft Learn

  5. #5
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    433
    not tested using WIA:

    Code:
    ' add reference to
    ' Microsoft Windows Image Acquisition Library
    Function GetLensModelFromImage(filePath As String) As String
        On Error GoTo ErrorHandler
        Dim imgFile As WIA.ImageFile
        Dim prop As WIA.Property
        Dim lensModel As String
        
        ' Initialize the WIA ImageFile object
        Set imgFile = New WIA.ImageFile
        imgFile.LoadFile filePath ' Load the specified image file
    
    
        ' Loop through the properties to find the Lens Model
        For Each prop In imgFile.Properties
            If prop.Name = "Lens Model" Then
                lensModel = prop.Value
                GetLensModelFromImage = lensModel
                Exit Function
            End If
        Next prop
    
    
        ' If no lens model is found, return a default message
        GetLensModelFromImage = "Lens Model not found in metadata."
        Exit Function
    
    
    ErrorHandler:
        GetLensModelFromImage = "Error: " & Err.Description
    End Function

  6. #6
    Miles R is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Mar 2019
    Posts
    280
    Forgot to mention one other advantage of using ExtendedProperty is the text it returns.
    For example, getting the Horizontal Resolution, ExtendedProperty returns a string of "72" (for example),
    whereas GetDetailsOf returns "?72 dpi", so string manipulation is needed to extract the 72 value.

    JoJoWhite, I assume your post was in reference to getting the Offset values needed if you use the GetDetailsOf method. I actually do it a slightly different way using :

    Code:
    ' Routine to look for a particular File Attribute
    Private Function gGetOffset(pstrAttribute As String)
        Dim intItem As Integer
        Dim strHeaderInfo As String
        Dim intMaxAttrNo As Integer
        
        ' Loop through all Metadata looking for a match, exit when found.
        intMaxAttrNo = 400      ' Arbitrarily high value.
        For intItem = 0 To intMaxAttrNo
            strHeaderInfo = gobjFolder.GetDetailsOf(gobjFolder.Items, intItem)
            
            If strHeaderInfo = pstrAttribute Then
                Exit For
            End If
        Next
        
        gGetOffset = intItem
    End Function
    I see though that your method was to find the specific lens model for an image. Surely that would be inefficient if you need to get the details for hundreds of files as I do. You don't want to have to be looping through all the MetaData for each image. Just get the offset first and then you can look up the value using GetDetailsOf. Or as I now prefer, just use ExtendedProperty with the specific text string.
    Last edited by Miles R; 01-28-2025 at 05:00 AM. Reason: Deeper reading of post

  7. #7
    Miles R is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Mar 2019
    Posts
    280
    Further info on using ExtendedProperty
    Sometimes it seems GetDetailsOf is more useful. e.g. ExtendedProperty("System.Photo.ISOSpeed") returns "400" for example, but GetDetailsOf returns "ISO-400"

    The big bugbear for me though is ExtendedProperty("System.Photo.ExposureTime"), which returns a fraction - e.g "0.0125", but GetDetailsOf returns "?1/80 sec."

    Much easier to extract 1/80 sec from the string than convert 0.0125 to a fraction.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 06-07-2024, 11:13 AM
  2. Get Extended property for specific file
    By Middlemarch in forum Access
    Replies: 12
    Last Post: 03-22-2024, 05:14 PM
  3. Replies: 9
    Last Post: 03-30-2021, 03:13 PM
  4. Replies: 6
    Last Post: 12-03-2013, 02:59 AM
  5. Replies: 1
    Last Post: 11-23-2012, 10:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums