Question

I want to determine programmatically if my shell extension is called as a context menu handler or a drag-n-drop handler. I have registered my shell extension in proper location with same CLSID.

Registry:

[HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\{E991C840-C1EB-455C-AD64-282473005C58}]
@="Test Context Menu"

[HKEY_CLASSES_ROOT\Directory\shellex\DragDropHandlers\TestDragDrop]
@="{E991C840-C1EB-455C-AD64-282473005C58}"

I have no problem with registry, my extension is loaded.

I think best place to check want be in DllGetClassObject or in IShellExtInit::Initialize.

Was it helpful?

Solution

You can detect type of extension with which shell wants to work only inside IShellExtInit.Initialize. For context menu handler pidlFolder is zero, for drag and drop handler pidlFolder is PIDL of folder.

OTHER TIPS

If you use the same CLSID for multiple extensions, then it does not know which extension is being instantiated, except maybe in QueryInterface() when the system queries for IContextMenu. If you really need to differentiate, it is best to just use separate CLSIDs, like Raymond Chen said. They can map to the same DLL, but that gives your code a chance to know which CLSID is being instantiated.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top