How to perform operations after the shell complete the drag&drop in a COM Drag&Drop Handler?

100 views Asked by At

On Windows, I want to have a folder named Automatic Folder. When I drag and drop something in it, the folder rename itself Folder 1 and a new empty Automatic Folder is created. Ending up with two folders:

  1. Folder 1 : containing the dragged and dropped files.
  2. Automatic Folder : empty, ready for a new drag and drop in it.

To achieve this goal, I implemented the IShellExtInit and IContextMenu interfaces in a C++ DLL and I edited my registry to inform the shell to call my DLL when someone drag and drop something in a folder. When my DLL is called, I rename the folder and create a new one. It works, but (as the Windows documentation point it out) this happens before the shell complete the drop operation. And when the shell finish the drop, it put the dragged and dropped files into the Automatic Folder while I expected the shell to put them into the Folder 1. (I hoped the shell identify folders by an ID that doesn't change on rename)

My question: Is there a way to end up with the files into the Folder 1 ? Either by:

  1. Telling the shell to call my DLL after the drop complete.
  2. Telling the shell to execute the SHFileOperationW and CreateDirectoryW calls, I make to rename and create folders, later.
  3. Redirecting the drag and drop targeted folder.
  4. Any other solution (if possible, other than waiting 1 second hoping the shell finished before renaming the folder).

I tried:

  1. Setting up the FOF_WANTMAPPINGHANDLE flag and giving a HANDLETOMAPPINGS during the SHFileOperationW call, hoping the shell will do some mapping.
  2. Calling SHChangeNotify after the renamed, to notify a folder has been renamed.
  3. Having the shell asked for an IDropTarget interface, (hoping it will open new doors) but it seems to be possible only when you drag and drop onto a file, not a folder.

I wish you a nice day :)

0

There are 0 answers