Results 1 to 19 of 19

Thread: [.NET 3.5+] ShellFile - Managed Wrapper To Retrieve Extended Properties

Threaded View

  1. #1

    Thread Starter
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    [.NET 3.5+] ShellFile - Managed Wrapper To Retrieve Extended Properties

    This was created as a response for this thread. Basically, it is a way to read (not write) all those extra properties that Windows has. This code requires a reference to "Microsoft Shell Controls And Automation" which is under the COM tab.

    You also need to add the ShellFile.vb file to your project.

    In the example I will retrieve the frame width of a video:

    Name:  details.png
Views: 5826
Size:  30.8 KB

    Code:

    Code:
    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, _
                                  ByVal e As System.EventArgs) _
                                  Handles Button1.Click
    
            '//create the wrapped file by passing in a path to a file
            Using file = New ShellFile("C:\Users\Public\Videos\Sample Videos\Wildlife.wmv")
    
                '//access the extended property by name (case insensitive search)
                Dim frameWidth = file.ExtendedProperties("frame width")
    
                '//check for nothing because if you attempt to index a property
                '//that doesn't exist then it will return null (nothing)
                If frameWidth IsNot Nothing Then
                    MessageBox.Show(frameWidth.Value)
                End If
            End Using
        End Sub
    
    End Class
    Output:

    Name:  output.png
Views: 5195
Size:  6.3 KB

    You can refer to this to see a relatively current list of valid extended properties by operating system. Or, you can just output all the extended property names that the code produces.

    This code was tested on x64 Windows 7 Home Premium. Code contains Xml commenting as well.
    Last edited by ForumAccount; Jul 22nd, 2011 at 11:02 AM. Reason: Applied different styling

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width