Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append to the default tooltip in a shell extension

I have a shell extension built using SharpShell. I am wondering if it is possible to append to the tooltip you see when you mouse over a file:

enter image description here

I have read and tried to use a Shell Info Tip Handler, but the problem with this is that it overrides the entire tooltip with what you set it to, instead of giving you the ability to append a line of text to the default tooltip you normally would see, which is my desired outcome.

I have a feeling this may not be supported in SharpShell, as a result, it would help for me to get insights from people as to how I could additionally approach this problem within MSVC++ shell extensions as well.

like image 430
Alexandru Avatar asked Sep 08 '16 18:09

Alexandru


1 Answers

This is possible, but not through a shell tooltip extension. Instead, through a shell property handler. The Recipe Property Handler is documented here and can be downloaded in full from this repository. Here's a picture of it in action in Windows 10:

enter image description here

It essentially adds extra file properties to the PerfectSteaks.recipe file by registering itself as a property handler, such as the property for Recipe difficulty who's key is Microsoft.SampleRecipe.Difficulty and can easily be set to show in Explorer by modifying the HKCR key HKEY_CLASSES_ROOT\SystemFileAssociations\.recipe to have InfoTip (of type REG_SZ) set as prop:System.ItemType;System.Author;System.Rating;Microsoft.SampleRecipe.Difficulty which causes it to display.

The properties are stored within the file itself. The .recipe file is an XML file which contains, among other things, the actual difficulty which the handler retrieves:

<RecipeInfo>
    <Difficulty>Hard</Difficulty>
    <PreparationTime>5</PreparationTime>
    <CookTime>20</CookTime>
    <Yield>2 servings</Yield>
</RecipeInfo>

This is not something unique these days because a lot of file formats do provide some form of extra internal API for storage. If you are working with Office files (which I am), you may notice they expose properties for storage within them for persistence using OLE. The DSOFile.dll (click here to download the source) is of utmost interest for Office files, and generally other files too. You will see it tries OLE storage within the Office file format itself, barring that it tries the Microsoft Office Metadata Handler for storage. If that fails, it finally tries using alternate streams (not a fan of alternate streams myself because they won't persist).

So that being said, with a combination of a shell property handler and similar tactics to DSOFile.dll, you can merge a solution for getting this job done in a proper way.

like image 72
Alexandru Avatar answered Nov 02 '22 07:11

Alexandru