Showing custom file properties in the Windows Expl

2019-09-13 18:22发布

问题:

I have used the DSOFile library, available within the Microsoft Developer Support 2.1 OLE File Property Reader 2.1 sample to set a custom file property for a file (sidenote, the sample has been updated in version 2.1 to handle non-OLE files, such as the new Office 2007 file formats, if a custom property handler is available):

SetCustomProperty(@"C:\Users\User\Desktop\Example.doc", "CustomProperty", "CustomValue");

public static void SetCustomProperty(string filename, string key, object value)
{
    var properties = new OleDocumentPropertiesClass();
    properties.Open(filename, false, dsoFileOpenOptions.dsoOptionDefault);
    var found = false;
    foreach (CustomProperty property in properties.CustomProperties)
        if (property.Name == key)
        {
            found = true;
            property.set_Value(ref value);
        }
    if (!found)
        properties.CustomProperties.Add(key, ref value);
    properties.Close(true);
}

Now that its been set for Example.doc, can I display it as part of the default tooltip for that document type? For example, in Windows Explorer when you hover over a document you will see its tooltip:

I have tried adding an InfoTip property (of type REG_SZ) inside of the registry key HKEY_CLASSES_ROOT\.doc with a value of prop:CustomProperty but it did not show up after restarting Explorer. Is my syntax off, or did I do something wrong? Is it even possible?