When a user right-clicks and drags a file into a different directory, they are presented with a small context menu that includes entries such as Copy here and Move here:

Is there a way to query these menu items yourself?
I was able to trigger the default implementation for this right drag-and-drop popup by following these steps:
- Register your app with
RegisterDragDrop. - In the
IDropTarget::Dropmethod:- Obtain the
IShellFolderinterface for the drop path. - Get the
IDropTargetinterface from this folder. - Forward the
IDataObjectto theDragEnterandDropmethods. - The
Dropmethod will display the correct context menu.
- Obtain the
Here's the simplified version of the code:
HRESULT Win_DragDropTargetDrop(IDropTarget *iTarget, IDataObject *iData, DWORD keys, POINTL cursor, DWORD *effect)
{
HRESULT hr = 0;
IShellFolder *folder = null;
IDropTarget *folderDropTarget = null;
POINTL pt = {0};
hr = Win_GetIShellFolder(hwnd, dragDropPath, &folder);
hr = folder->lpVtbl->CreateViewObject(folder, hwnd, &IID_IDropTarget, &folderDropTarget);
hr = folderDropTarget->lpVtbl->DragEnter(folderDropTarget, iData, MK_RBUTTON, pt, effect);
hr = folderDropTarget->lpVtbl->Drop(folderDropTarget, iData, MK_RBUTTON, pt, effect);
}
However, what I want is to enumerate these items within IContextMenu myself, using functions such as CreatePopupMenu, QueryContextMenu, and then iterating through that menu via GetMenuItemCount and GetMenuItemInfo.
The reason is that I'm rendering the context menu myself (instead of using the Windows built-in UI framework). I'm already doing this for the regular right-click context menu on a directory background.
