?
Solved

How to read file properties from the Summary tab in XP

Posted on 2006-04-07
22
Medium Priority
?
429 Views
Last Modified: 2008-01-09
When you right-click a file and go to Properties and then go to the Summary tab, there are several extra pieces of information being displayed (title, company, etc...).  How can you read this information via VB or VB.NET?  

I have tried using the DSO library from MS, but it doesn't work, it only works on MS documents.  I have read tons tons of posts in EE and via Google but not a single one has the solution; I've tried them all.

The reason I need this is because I am writing a small app that will read an MP3 file, extract the SongName and rename the file based on the SongName tag.  I have this working beautifully.  But, I have some files that do not have MP3 tag (or at least not that I can read in code), but it does have the proper name in the Title property on the Summary tab.  So, if I can't get the SongName from the MP3 tags, then I want to look at the Title property and use that (if it exists).

Things I have tried already:

1)  Using FSO (File System Object) - Not even close
2)  Using DSO - Not even close, only worked on MS docs
3)  Using reflection to get the assembly data; this one worked, but only for my running application, I couldn't figure out any way to specify what file's assembly data I wanted to read - THIS WAS THE CLOSEST
4)  Searching Google for a couple of hours - Nothing turned up
5)  Searching previous EE posts on the subject for a couple of hours - No actual working, accepted answers
6)  Searching MSDN for a couple of hours

Can anyone help with this?  Thank you all in advance.  

And yes, I know that there are some other programs already out there that I could use to do this for me, but that's not what I want; I want my own code and my own application that does this.  Many thanks.
0
Comment
Question by:codeconqueror
  • 10
  • 10
  • 2
22 Comments
 
LVL 14

Expert Comment

by:PockyMaster
ID: 16403723
Windows reads the MP3 tags as well, I've written some code to read all the tags from my own mp3s, and it was working for most of them. Most of the current MP3s seems to be using V2.
for the specification
http://www.id3.org/

If you look at ID3 you can find a lot of examples that are working, or with the description is not that much work to create it yourself.
0
 
LVL 14

Expert Comment

by:PockyMaster
ID: 16403732
Note: when I said, windows reads the MP3 tags as well, I assume that, since when I modify them, somehow Windows seems to know about that as well :D
0
 
LVL 5

Author Comment

by:codeconqueror
ID: 16404431
I can already read the MP3 tags.  I am getting the SongName, Artist, Album, etc...  The problem is that some of the files I have because of the way they were ripped, do not have the normal MP3 tags for some reason.  When I extract the tag and check if it's = TAG it's not (but only for these specific mp3s), but it does have the song name in the Title property of the Summary tab in file properties.  I need to read that Title property.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 14

Expert Comment

by:PockyMaster
ID: 16404454
if you read the first couple bytes, what does it say? ID3?
0
 
LVL 5

Author Comment

by:codeconqueror
ID: 16404597
Here is the function I'm using:

When I check the first 3 characters (TAG), for this particular file it ends up blank.

Look for in the ProcessFile function posted below (am I perhaps doing something wrong?  It works for all my other MP3s):
<CODE SNIPPET>
                        FileGet(intFileHandle, sTag, lngLOF - 127, True)
                        If sTag.ToUpper <> "TAG" Then
</CODE SNIPPET>

<CODE SNIPPET>
      Private Function ProcessFile(ByVal FileNameAndPath As String, ByVal OutputPath As String) As Integer
            'Return values: 0=OK, 1=File to read doesn't exist, 2=Output path doesn't exist, 3=No MP3 tag to read
            Dim iretProcessed As Integer = 0
            If System.IO.File.Exists(FileNameAndPath) And System.IO.Directory.Exists(OutputPath) Then
                  Dim intFileHandle As Integer = FreeFile()
                  Dim sTag As New String(CType(" ", Char), 3)
                  Dim sSongName As New String(CType(" ", Char), 30)
                  Dim sArtist As New String(CType(" ", Char), 30)
                  Dim sAlbum As New String(CType(" ", Char), 30)
                  Dim sYear As New String(CType(" ", Char), 4)
                  Dim sComment As New String(CType(" ", Char), 28)
                  Dim btGenre As Byte
                  Dim btTrack As Byte
                  Dim btDummy As Byte
                  FileOpen(intFileHandle, FileNameAndPath, OpenMode.Binary, OpenAccess.Read, OpenShare.LockWrite)
                  Dim lngLOF As Long = LOF(intFileHandle)
                  If lngLOF > 128 Then
                        FileGet(intFileHandle, sTag, lngLOF - 127, True)
                        If sTag.ToUpper <> "TAG" Then
                              iretProcessed = 3
                              FileClose(intFileHandle)
                        Else
                              FileGet(intFileHandle, sSongName)
                              FileGet(intFileHandle, sArtist)
                              FileGet(intFileHandle, sAlbum)
                              FileGet(intFileHandle, sYear)
                              FileGet(intFileHandle, sComment)
                              FileGet(intFileHandle, btDummy)
                              FileGet(intFileHandle, btTrack)
                              FileGet(intFileHandle, btGenre)
                              FileClose(intFileHandle)
                              sSongName = Trim$(sSongName)
                              sArtist = Trim$(sArtist)
                              sAlbum = Trim$(sAlbum)
                              sYear = Trim$(sYear)
                              sComment = Trim$(sComment)
                              lblSongName.Text = sSongName
                              lblArtist.Text = sArtist
                              lblAlbum.Text = sAlbum
                              lblYear.Text = sYear
                              lblComment.Text = sComment
                              lblGenre.Text = TranslateGenre(btGenre)
                              lblCurrentFile.Text = FileNameAndPath
                              Me.Refresh()
                              Application.DoEvents()
                              sSongName = Replace$(sSongName, Chr(0), "", 1, -1, CompareMethod.Text)
                              sSongName = Replace$(sSongName, Chr(34), "", 1, -1, CompareMethod.Text)
                              sSongName = Replace$(sSongName, "\", "", 1, -1, CompareMethod.Text)
                              sSongName = Replace$(sSongName, "/", "", 1, -1, CompareMethod.Text)
                              sSongName = Replace$(sSongName, "?", "", 1, -1, CompareMethod.Text)
                              sSongName = Replace$(sSongName, "!", "", 1, -1, CompareMethod.Text)
                              sSongName = Replace$(sSongName, "*", "", 1, -1, CompareMethod.Text)
                              If sSongName Is Nothing Then
                                    sSongName = GetFileTitle(FileNameAndPath)
                              Else
                                    If sSongName.Length = 0 Then
                                          sSongName = GetFileTitle(FileNameAndPath)
                                    End If
                              End If
                              If sSongName IsNot Nothing Then
                                    If sSongName.Length > 0 Then
                                          sSongName = sSongName & ".mp3"
                                          lblOutputFile.Text = OutputPath & "\" & sSongName
                                          If GetFolderName(FileNameAndPath) = OutputPath Then
                                                Rename(FileNameAndPath, OutputPath & "\" & sSongName)
                                          Else
                                                FileCopy(FileNameAndPath, OutputPath & "\" & sSongName)
                                          End If
                                    Else
                                          iretProcessed = 3
                                    End If
                              Else
                                    iretProcessed = 3
                              End If
                        End If
                  Else
                        FileClose(intFileHandle)
                  End If
            Else
                  If Not System.IO.File.Exists(FileNameAndPath) Then
                        iretProcessed = 1
                  ElseIf Not System.IO.Directory.Exists(OutputPath) Then
                        iretProcessed = 2
                  End If
            End If
            Return iretProcessed
      End Function
</CODE SNIPPET>

If you want I can send you or post the MP3 file if that might help.  Thanks for your assistance.  :)
0
 
LVL 5

Author Comment

by:codeconqueror
ID: 16404604
If I let it pass through anyways if it is <> "TAG", then it just returns blank entries for the rest of the properties and 0 as the byte for genre, track.
0
 
LVL 14

Expert Comment

by:PockyMaster
ID: 16404618
ID3 v1  starts with TAG
ID3 v2 starts with ID3

on the ID3.com website you can find classes doing the work for you or you can google for them..
Or you can read the specifications and make it yourself :D
0
 
LVL 14

Expert Comment

by:PockyMaster
ID: 16404625
Yeah, because the specification is different from v2 :D
0
 
LVL 14

Expert Comment

by:PockyMaster
ID: 16404639
http://www.ambientware.com/components/ID3Util.aspx

didnt try this, but they say its free and deliver source code for use with .NET
0
 
LVL 5

Author Comment

by:codeconqueror
ID: 16404644
I'm not even getting the ID3, I'm getting a blank string ("").  If it said ID3, then yeah I'd make the appropriate changes.  But I reviewed the ID3 stuff at the link you sent and this code should at least get ID3 where I'm looking for "TAG", but I'm not even getting that.  Am I doing something wrong in my code to where I wouldn't get ID3 but I would get TAG?  Nothing jumped out at me as being incorrect.
0
 
LVL 5

Author Comment

by:codeconqueror
ID: 16404651
Interesing link from ambientware, hadn't run into that one.  I'll have to look at and see if I see anything that might help.  Thanks.  I'll repost my results.  If you find out anything (or see something in my code) in the meantime, let me know.
0
 
LVL 14

Accepted Solution

by:
PockyMaster earned 2000 total points
ID: 16404708
There are also other Tag systems (e.g. APE) They can be written on the end of the file as well :D
0
 
LVL 14

Expert Comment

by:PockyMaster
ID: 16404719
0
 
LVL 14

Expert Comment

by:PockyMaster
ID: 16404722
0
 
LVL 12

Expert Comment

by:omegaomega
ID: 16415048
Hello, CodeConquerer,

Re: "I have tried using the DSO library from MS, but it doesn't work, it only works on MS documents."

Do you mean DSOFile.dll?  (http://support.microsoft.com/?id=224351).

This works on "other" files, but there is a problem creating the properties if they don't already exist.  If this is the problem, see the article at http://www.codecomments.com/archive293-2006-2-813451.html for a possible workaround.  (I haven't yet tried this, but hope it works because I will need it soon.)

Cheers,
Randy
0
 
LVL 5

Author Comment

by:codeconqueror
ID: 16416057
Yes, DSOFile.dll (I believe that's the filename).

The properties already exist, I just need to read them.
0
 
LVL 12

Expert Comment

by:omegaomega
ID: 16416261
Hello, CodeConqueror,

What specifically is the problem?  The following sequence works for me in a customized FileStream class.

    Private mdsoFileProps As New DSOFile.OleDocumentPropertiesClass   ' File properties object.
    Private mfspFileProps As DSOFile.SummaryProperties                ' Summary properties collection.
    . . .
    mdsoFileProps.Open(Me.Name)                                  ' Me.Name is the file name whose properties are to be accessed.
    mfspFileProps = mdsoFileProps.SummaryProperties

    ' In "Title" Get property of customized class:
    . . .
            Return mfspFileProps.Title
    . . .

    End Property

As mentioned, I have a problem with the Set property.  But the Get property works fine.

Cheers,
Randy
0
 
LVL 5

Author Comment

by:codeconqueror
ID: 16418938
That works, just not for these MP3s.  I could only get it to work with some MS office docs and some other files, but not these MP3s.
0
 
LVL 5

Author Comment

by:codeconqueror
ID: 16418951
I'm still working on trying different MP3 formats to get it to work, but....

Back to my first question:  Does anyone know how to access the information on the Summary tab of a file when in XP w/ NTFS?  Thanks.

Thanks for your help so far guys.  Hopefully we can figure out how to do this.  :)
0
 
LVL 5

Author Comment

by:codeconqueror
ID: 16418963
Without using DSO preferably.  I'd like to avoid installing and registering more components if possible.
0
 
LVL 5

Author Comment

by:codeconqueror
ID: 16470437
Well, i figured out how to read the mp3 file properly (it was APE format).  Thanks for your help.

Although, this didn't directly answer my original posted question.  If anyone has any idea on how to read the summary properties, please let me know and I will open a new question and reward points.  For now, since I at least go past my problem, the point go to PockyMaster.  Thanks for your help.
0
 
LVL 14

Expert Comment

by:PockyMaster
ID: 16470564
You're welcome
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question