Search code examples
c++windowswinapishell-extensions

Shell extension windows : best communication between ContextMenu and IconOverlay?


Hello windows experts,

I am searching for a simple way to activate an overlay on files using the context menu. Tortoise SVN gives an example of what can be done. But is very complex compared to my simple need.

For now I am looking at approaching it this way using C++:

http://www.codeproject.com/Articles/545781/NET-Shell-Extensions-Shell-Icon-Overlay-Handlers

http://www.codeproject.com/Articles/10104/Add-a-context-menu-to-the-Windows-Explorer

The issue is to create the link between both of them. The following link suggests to make a map but I am quite puzzle about how:

What the best Language to use when creating Windows Shell Context Menu?


Solution

  • You can use the Registry, for example store an Enabled value in the HKEY_CURRENT_USER\YourCompany\YourApp key. When the user executes your menu item to turn on/off the functionality, write the appropriate value into Enabled and then call SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil). That will cause the shell to re-read icons, including icons from your overlay extension. Inside the IsMemberOf method of your IconOverlay handler, check your Enabled value and return S_FALSE if the functionality has been turned off.