File Cut/Copy/Paste/Rename - Windows Explorer Shell Extension
What we need is a technique to detect that a file or folder has been moved or renamed with Windows Explorer, bypass the standard Explorer behavior (i.e. we need to prevent Explorer from displaying its file move dialog, which manages conflicts between file names, allows to cancel the operation halfway, and so on), and execute our custom behavior (for example, write a log file, execute a command line, or something yet to be defined).
We're aware of two Open Source software doing that, but we don't know how they are doing it. Maybe their shell extensions are doing it, but we are not sure. These applications are:
we guess the code is int this file \SuperCopier\SC2C++\DDShellExt.cpp and probably also in other files in that folder.
we guess it’s in the folder \copy handler\src\chext.
Plus, there is this article (we don't know if this works and the technique is not explained):
So what we need from you is a (well commented) sample program which displays a dialog box when a file (or a group of files) is moved or renamed with Windows Explorer. The dialog box should say something like "detected movement of file PATH1 to PATH2".
- The sample program probably needs to be a shell extension, but, as we already mentioned, we are not sure of that;
- A filesystem minifilter would probably solve the problem, but we are not sure we can accept such a solution, because a filesystem driver is more complicated to install, and because it would then be more difficult to add our custom behavior in place of the dialog box.
- The sample program must not rely on the FileSystemWatcher or equivalent (as it is not reliable, and provides no “file moved” event).
- Only move operations done by Windows Explorer must be detected and prevented by your sample application; move operations done by other applications such as Microsoft Word must be ignored (i.e. Word must be able to perform the move operation successfully).
- Both move and rename operations must be detected by the sample program;
- Move and rename operation must be detected regardlessly of how they are executed: by pressing ctrl+x ctrl+v, by dragging a file with the left mouse button, by dragging a file with the right mouse button and then clicking “paste”, right-clicking a file and clicking paste, pressing F2, etc.
- It must be easy for us to extend and modify your sample application, removing the dialog box, and inserting the intended behavior, which is yet to be defined, but will probably reduce to calling a command line and possibly updating a text file, or maybe sending a windows message to some known HWND. Doing this is not your job, but the sample program must be extendible to do that.
- ICopyHook won't work as it only monitors folders and printer-objects.
- The language should be C# or C++. C# is much preferred. (Note that since .NET 4.0 it is possible to write shell extensions in managed code.)
- Move operations both within the same disk and across disks must be detected; the detection must work regardless of the file system (including Fat32, Ntfs, and network drives).
P.S.: check our software at http://tabbles.net :-)