次の方法で共有


Canonical Property Names

Most of the property system uses PROPERTYKEYs to identify properties. But you can also identify a property using its canonical name. For instance, PKEY_DateModified corresponds to L"System.DateModified". 

Whereas a PROPERTYKEY was good for coding and binary structures, the name is the ideal form for the registry or config files.  Canonical names are meant to be programmer friendly, composed of [0-9A-Za-z.], up to 63 characters long, and are structured as Company.Group.Property. The only exception to the naming convension is that the built-in system properties are named System.Group.Property. 

Anyway, converting between a canonical name and a key is easy. These two functions are very cheap (a hash table lookup, usually). 

// from propsys.h
HRESULT PSGetPropertyKeyFromName(__in PCWSTR pszName, __out PROPERTYKEY *ppropkey);
HRESULT PSGetNameFromPropertyKey(__in REFPROPERTYKEY propkey, __out PWSTR *ppszCanonicalName);

There's even a version of PSGetPropertyDescription that takes canonical names...

PSSTDAPI PSGetPropertyDescriptionByName(LPCWSTR pszCanonicalName, __in REFIID riid, __deref_out void **ppv);

Comments

  • Anonymous
    September 12, 2006
    glad to see posts on the Vista property system! good stuff.