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:
- Folder 1 : containing the dragged and dropped files.
- 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:
- Telling the shell to call my DLL after the drop complete.
- Telling the shell to execute the
SHFileOperationWandCreateDirectoryWcalls, I make to rename and create folders, later. - Redirecting the drag and drop targeted folder.
- Any other solution (if possible, other than waiting 1 second hoping the shell finished before renaming the folder).
I tried:
- Setting up the
FOF_WANTMAPPINGHANDLEflag and giving aHANDLETOMAPPINGSduring theSHFileOperationWcall, hoping the shell will do some mapping. - Calling
SHChangeNotifyafter the renamed, to notify a folder has been renamed. - Having the shell asked for an
IDropTargetinterface, (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 :)