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.

有帮助吗?

解决方案

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.

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top