0

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:

enter image description here

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?

Alexandru
  • 12,264
  • 17
  • 113
  • 208
  • That requires an "infotip shell extension handler". A completely different kettle of fish from what you've been talking about. You should never write them in a managed language like C# and doing so is officially unsupported. Starter MSDN page [is here](https://msdn.microsoft.com/en-us/library/windows/desktop/cc144067(v=vs.85).aspx). – Hans Passant Sep 09 '16 at 14:39
  • @HansPassant No, I don't think so. Can you elaborate as to why? That would override the entire tooltip with values from a handler, but I just want the default shell to change the HKCR values it displays in the tooltip, which is totally different. Check your HKCR in regedit for ToolTip properties and how some apps show tooltip property values like internal resources within files, hardcoded strings, etc. – Alexandru Sep 09 '16 at 14:49
  • @HansPassant In other words, see why that's got its own problems here: http://stackoverflow.com/questions/39398084/append-to-the-default-tooltip-in-a-shell-extension – Alexandru Sep 09 '16 at 15:16

0 Answers0