views:

433

answers:

3

Is there any way to detect whenever a copy operation starts in Windows Explorer.

kind of like in SuperCopier : SuperCopier Website ?

and log files involved in the operation ? and such ?

I've browsed through Supercopier code and I can't find the part which deals with detecting the copy operation, as I'm not fluid in Delphi.

P.S : it seems they are using a Shell Extension ...not sure though.

+5  A: 

Yes, you can.

You have to implement a shell extension which has to hook the file copy operation. There are plenty of examples of how to do these things in C++ (using the native Win32 API) and also using C# or other .NET framework languages. I'm sure you can use Delphi too but I don't know the details involved in making the Win32 API calls..

Here's an article which details the implementation of a simple shell extension in C#.

Of course, you may also want to take a look at windows file I/O filters, although they only allow you to observe file operations such as creating, copying, changing or deleting. In .NET creating a file I/O filter is trivial using the System.IO.FileSystemWatcher class and if all you want is to detect and log such file copy operations it may be all you need to do.

NOTE If you decide to implement a shell extension in C#, you should know that it will only work on operating systems where the .NET framework has been installed (the version that you used to create the extension) - although most people now have at least .NET 1.1, and 2.0..

Miky Dinescu
i'm interested in using C# .NET to do it.
Attilah
then take a look at those links. there's a little bit of reading to do but implementing shell extensions in C# is not too hard.
Miky Dinescu
Implementing Shell Ext in .NET is a no-nohttp://blogs.msdn.com/junfeng/archive/2005/11/18/494572.aspx.You will need to use a thin C++ wrapper + IPC into a .NET process.
Shay Erlichmen
well, I wouldn't say it's a no-no. Certainly it will be less-and-less of a no-no as Microsoft migrates more-and-more of the windows core towards .net. At any rate, it depends heavily on what the purpose of the extension is - i.e. public or private for your own amusement, in your own controlled environment
Miky Dinescu
It ++is++ a no-no, because only one version of the .NET framework can be loaded into a process at a time. Choosing .NET 2.x for your shell extension would prohibit any others using .NET 1.x or 3.x from being loaded. And MS isn't migrating *any* of the Windows core toward .NET - .NET is an add-on on ++top++ of the Windows core (IOW, you have your dependencies reversed - .NET relies on the core and not the other way around).
Ken White
+4  A: 

Examples of creating a copy hook shell extension can be found in the installation delphi folder \Demos\ActiveX\ShellExt\copyhook.dpr

Here you have another additional example

Bye.

RRUZ
yeah, this is surely the way to go as it seems easier and less painful to write such tools with Delphi.
Attilah
A: 

You don't need any Shell extension.
You just have to hook Shell apis.

marcus