Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does windows explorer store file meta data?

In Windows 7 I can add meta data to files for example title, rating and so on. Where is this meta data stored exactly? For NTFS they may use alternate data streams but I this meta data also happen to work in FAT32, so how ho they do it? Is there an API to make use of this feature?

like image 903
codymanix Avatar asked May 21 '11 07:05

codymanix


1 Answers

In Windows 7 I can add meta data to files [using Explorer] for example title, rating and so on. Where is this meta data stored exactly?

This metadata is called properties. It has been available in this way since Windows Vista.

Windows Explorer presents properties in a unified way, which might trick you into thinking that they're all coming from the same shop. But this is not the case.

Properties are exposed to the programmer via an API. (See below.)

Where exactly they're stored is an implementation detail. It depends on the filetype and on the kind of property. For example, filesystem timestamps are exposed as properties. Media file metadata such as EXIF for images or ID3 tags for MP3 is stored in the file itself. Still other metadata might be stored in an XML file accompanying the file whose properties you're inspecting.

So where is it stored? The answer is: It really depends, and you really don't have to worry, nor should you worry. Because, as I said, it is an implementation detail, and as far as programming goes, worrying about implementation details means bypassing the API.

Neither do you have to worry where properties are stored when dealing with them at the API level. See the IShellItem2 and IPropertyStore COM interfaces for an entry point.

Under the hood, Windows Vista and later versions ship property handlers that know about filetypes and how to read and write their properties. You could write a property handler of your own (using COM) and add it to Explorer (as a so-called shell extension).

The most useful documentation which I've found is Ben Karas' blog entries around the time of the Vista release starting in August 2006. He's done a whole series on the property system. It's a very useful tutorial, and for me using Windows 7, it has worked 100 %.

Don't follow the advice given in another reply on this page to read up about COM Structured Storage. This is only for specific filetypes. In the words of Ben Karas:

Gotcha: Many people mistakenly call StgOpenStorageEx. Don't do that! StgOpenStorageEx is only supported for specific formats like OLE Compound Documents or NTFS secondary stream storage. StgOpenStorageEx doesn't know how to read the EXIF header from a .JPG image.

like image 115
Lumi Avatar answered Oct 25 '22 00:10

Lumi