I'm going to make a first stab at printing out a list of properties that are writable for a given file.  I'll spoil the fun and let you know that my attempt today will not fully succeed.  I'll explain later.  For now, let's see some code!

You'll recall I wrote a program to loop through the properties in a file and dump them out.  I am going to simply modify that program to only print out those properties that pass my _IsPropertyValueWritable() test from last time.  Here's the new function for printing a property store:

HRESULT _PrintPropertyStore(IPropertyStore *pps)
{
    DWORD cProps;
    HRESULT hr = pps->GetCount(&cProps);
    for (DWORD i = 0; SUCCEEDED(hr) && i < cProps; i++)
    {
        PROPERTYKEY key;
        hr = pps->GetAt(i, &key);
        if (SUCCEEDED(hr))
        {
            if (_IsPropertyValueWritable(pps, key))
            {
                PROPVARIANT propvar = {0};
                hr = pps->GetValue(key, &propvar);
                if (SUCCEEDED(hr))
                {
                    hr = _PrintPropertyValue(key, propvar);
                    PropVariantClear(&propvar);
                }
            }
        }
    }
    return hr;
}

Now let's run this on my favorite goat picture:

Writeable Properties for 'scan0010.jpg'
System.Photo.Saturation: VT_UI4: 0 --> Normal
System.Photo.EXIFVersion: VT_LPWSTR == 0220
System.Rating: VT_UI4: 99 --> 5 Stars
System.Photo.DateTaken: VT_FILETIME: 2006/07/30:00:33:34.000 --> 7/29/2006 4:33 PM
System.Photo.CameraManufacturer: VT_LPWSTR == HP
System.Photo.CameraModel: VT_LPWSTR == HP Scanjet 4370
System.Photo.Sharpness: VT_UI4: 0 --> Normal
System.Title: VT_LPWSTR == Mountain goat
System.Author: VT_VECTOR|VT_LPWSTR == Ben Karas
System.Keywords: VT_VECTOR|VT_LPWSTR == Sol Duc Valley; Wildlife

What, that's it?  Just ten (10) properties are writable to JPGs?  Why, the properties details dialog shows more than that!  Obviously something is missing.  I'll get into that next time.