1

I'd like to create a new stub file "test.mp3" for instance, and add a Window Property to it ( System.Author for instance).

the solution must be usable for several file extension as text, picture, videos, etc...

If I just create a file and use IShellItem2::GetPropertyStore I get a HRESULT fail for invalid Arguments.

Use IShellItem2::GetPropertyStore on a real music file I can read and write Its properties just fine.

Please test your suggestions first.

Carlos_rpg
  • 71
  • 1
  • 12

1 Answers1

2

Property Stores typically access and store data within the file itself. In your case of a mp3 file, it would be attempting to read and write the ID3 tags. Also, Property Stores are not stored in a database and cannot be arbitrarily added to files that don't support it.

You'll most likely need to implement your own property handlers to do what it appears you're trying to accomplish. For types that already have handlers, you'll have to replace the system handlers with your own.

The most likely reason your mp3 test is failing is that you have an empty file with no data and no valid ID3 tags.

Joshua
  • 8,112
  • 3
  • 35
  • 40
  • I did not understood your answer. I'm trying to use Windows Property System [link](http://msdn.microsoft.com/en-us/library/windows/desktop/ff728898(v=vs.85).aspx) I can use it to change whatever file that is saved with a PropertyStore. Let's say a word document, or a jpeg, or a mp3 file, etc. My question is: how to save a file with these properties.( like MS Word does for Author on doc files) – Carlos_rpg Feb 11 '14 at 20:35
  • 1
    That does not negate what Joshua said. You can't just read/write arbitrary properties on arbitrary files. The file type has to be registered with a handler that provides access to properties for that file type. Some file types have specific handlers implemented by Microsoft itself, others require third-party handlers. DOC, JPG, MP3 are file types that are specifically designed to hold metadata in the files themselves, via various embedded tags/blocks. TXT, for instance, does not support embedded metadata at all. – Remy Lebeau Feb 11 '14 at 20:40
  • I understand that, but it also does not answer my question. let's say I want to create a mp3 file with property Author set. How do I do It? – Carlos_rpg Feb 11 '14 at 20:54
  • You already know how since you said in your question "if I use a real file, it works fine." The answer to your question is you can't arbitrarily add tags to files that don't support it, and you need a valid file for the built-in handlers to work. For you to create your own file and tag it, you need to make a valid mp3 file with ID3 tags before Windows will work with it. – Joshua Feb 11 '14 at 22:00
  • I'm sorry. I did not understood the way you said it. I found that each property handler reads its property data from the file stream itself. this way I can write a mp3 file compatible with ID3 and the system handler for this kind of file will be loaded, Or I can override this handle and implement a new one were I can read the stream and extract the data from it myself (but in this case I must be ID3 compatible or my real files will no longer show its metadata). In the end would be better to store those info in a database and write a shell extension to display the info fetched from my DB. – Carlos_rpg Feb 11 '14 at 22:33
  • I guess this was exactly what you tried to say on the answer! I'm sorry. Answer Accepted! – Carlos_rpg Feb 11 '14 at 22:34