Property consumerism
Reading properties is rather simple. First, bind to the item. SHCreateItemFromIDList and SHCreateItemFromParsingName are appropriate for this. Then read your properties. Be sure to clean up after yourself.
IShellItem2 *psi;
if (SUCCEEDED(SHCreateItemFromParsingName(L"c:\tortoise.doc", NULL, IID_IShellItem2, (void**)&psi)))
{
IPropertyStore *pps;
if (SUCCEEDED(psi->GetPropertyStore(GPS_DEFAULT, IID_IPropertyStore, (void**)&pps)))
{
PROPVARIANT propvar = {0};
if (SUCCEEDED(pps->GetValue(PKEY_Title, &propvar)))
{
wprintf(L"Title: %s\n", PropVariantToStringWithDefault(propvar, L"<none>"));
PropVariantClear(&propvar);
}
pps->Release();
}
psi->Release();
}
Not bad for reading the title of a document! And I even checked the return results.
Comments
- Anonymous
August 30, 2006
So what's this PROPERTYKEY that the property system uses?&nbsp; Where do I get them?
Well, property... - Anonymous
January 24, 2007
In this series, I will be presenting Windows Vista functionality with a focus on the the file system