Append to the default tooltip in a shell extension

蓝咒 提交于 2019-12-10 13:31:59

问题


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:

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.


回答1:


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:

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.



来源:https://stackoverflow.com/questions/39398084/append-to-the-default-tooltip-in-a-shell-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!