user3237732
user3237732

Reputation: 2038

Windows Shell extention: context menu when more than 16 files are selected

As I can see, when more than 16 files are selected DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0); returns 16. MSDN: http://msdn.microsoft.com/en-us/library/dd758093%28VS.85%29.aspx "In Windows 7 and later, the number of items passed to a verb is limited to 16 when a shortcut menu is queried. The verb is then re-created and re-initialized with the full selection when that verb is invoked."

But my FileContextMenuExt::Initialize function is called only once, even if I select more than 16 files. (I checked it out using output to text file).

How can I get full list of selected files and its number?

My question is similar to Shell Extension: DragQueryFile returns at most 16 (in Windows 7) but no solution were found there. Can anyone help me?

Upvotes: 3

Views: 651

Answers (1)

Anya Shenanigans
Anya Shenanigans

Reputation: 94859

The logic is really quite simple in this case. When you right-click up to 16 items will be sent to the IShellExt::Initialize method, followed by the IContextMenu::QueryContextMenu

In the case that your verb is invoked (i.e. the IContextMenu::Invoke is called) there are two possible paths:

Up to and including 16 items in the selection -> IContextMenu::Invoke is called directly.

More than 16 items in the selection then the IShellExt::Initialize method is invoked a second time with all the items of the selection, followed by IContextMenu::Invoke.

If you never invoke the menu item, then you will never get the second call to IShellExt::Initialize with the full list of items.

I've a sample project on github that creates a simple context menu (using C++), which demonstrates the behavior using the truly low-level OutputDebugString.

Upvotes: 3

Related Questions