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>”));

Not bad for reading the title of a document!  And I even checked the return results.

Comments (2)

  1. So what’s this PROPERTYKEY that the property system uses?&amp;nbsp; Where do I get them?

    Well, property…

  2. In this series, I will be presenting Windows Vista functionality with a focus on the the file system