What is a PROPERTYKEY?

So what's this PROPERTYKEY that the property system uses? Where do I get them?

Well, property keys identify the particular property you are interested in. You can find a bunch of system-provided definitions in the Windows Vista Platform SDK in propkey.h. You'll find that most of the property system APIs refer take a PROPERTYKEY.  

typedef struct {
GUID fmtid;
DWORD pid;
} PROPERTYKEY;

Each PROPERTYKEY is a GUID and a DWORD. These are named the FMTID and the PID, respectively. What makes this structure nice is that you can store them stack variables. They are efficient to store in data structures and efficient in comparisons. Perhaps the only downside is that you cannot use a switch statement on property keys.

As you saw last time, you can pass the system keys around by reference just by referring to them by name.

That's all for now... I'll get into naming convensions and how to define your own property keys another time. 

Here's some example property keys the system defines.

PKEY_DateModified - The date and time of the last write to the item. The Indexing Service friendly name is 'write'.

PKEY_Rating - Indicates the users preference rating of an item on a scale of 0-99 (0 = unrated, 1-12 = One Star, 13-37 = Two Stars, 38-62 = Three Stars, 63-87 = Four Stars, 88-99 = Five Stars).

PKEY_Keywords - The keywords for the item. Also referred to as tags.