Context menu handler for folders

2019-09-10 11:17发布

问题:

I am trying to wrap my head around Microsoft's shell extension context menu handler example.

Its implementation only shows a context menu on a .cpp file right-click. I want to try to extend it to allow it to show the context menu whenever a folder, drive, or empty space is right-clicked in Explorer as well.

So far I was only able to modify it to register right-clicks for all file types, not just .cpp files by specifying * when registering it:

hr = RegisterShellExtContextMenuHandler(L"*", 
            CLSID_FileContextMenuExt, 
            L"CppShellExtContextMenuHandler.FileContextMenuExt");

I must be missing something else because it won't pop up for folders. I have tried this suggestion but it did not work.

How can I extend this sample to also have it work for folders? Am I missing something from the registry?

Edit: Thanks to Igor's suggestion, I got it to work for folders and drives, but it does not show up when you right-click the desktop or when you right click blank space in a folder, and I did register for Directory\Background and DesktopBackground. Why is this?