This project is read-only.

C# ICopyHook implementation based on CSShellExt*


Hi All,
Referring to my discussion entry ( I'd like to officially request a ICopyHook ShellExtension example written in C# (CLR 4.0). According to Jialiang this will be the next sample he will attack :). Looking forward to seeing a managed CopyHook extension!
Purpose: I'll need it for my application in order to provide better drag and drop support, i.e. to be able to get the drop target in Windows Explorer. See for more details why one need it.


Jialiang wrote Nov 10, 2010 at 7:00 AM


Thanks for submitting the code sample request!

Yes, I will look into this sample request and write it after I finish another shell extension sample.

ylangisc wrote Nov 15, 2010 at 8:44 AM

Just curious if this request is one the mentioned 5 which are already in development (

Great initiative btw!


ylangisc wrote Nov 23, 2010 at 10:18 PM

Any chance to give me an idea when this sample will be finished? Should know it if I need to make another attempt to implement it. Thanks!

wrote Dec 3, 2010 at 4:28 PM

nerdfactor wrote Dec 14, 2010 at 11:20 AM

is there any progress on this? i would really love to have something to work on over the holidays.

Jialiang wrote Dec 15, 2010 at 2:10 PM


I finally finished the preview handler sample requested by another customer on Monday, and I'm now full-time working on ICopyHook one. I will try my best to finish and publish the C# version before Christmas.

nerdfactor wrote Dec 15, 2010 at 2:29 PM

thats great news. really thankfull that you take some time out of your day to help

ylangisc wrote Dec 15, 2010 at 2:30 PM

Thanks Jialiang, your effort is very much appreciated! Yves

Jialiang wrote Dec 20, 2010 at 9:24 AM


I have finished the copy hook handler code samples. You can download them from:

CSShellExtCopyHookHandler (the .NET 4 C# version)
VBShellExtCopyHookHandler (the .NET 4 VB version)
CppShellExtCopyHookHandler (the C++ version)

The example copy hook handlers hook the renaming operation of folders in Windows Explorer. When you are renaming a folder whose name contains "Test" in the Shell, the copy hook handler pops up a message box, asking if the user really wants to rename the folder. If the user clicks "Yes", the operation will proceed. If the user clicks "No" or "Cancel", the renaming operation is cancelled.

In readme.txt of the samples, you can find the detailed demo steps, and implementation.

NOTE: You must restart Windows Explorer (explorer.exe) process after you install the copy hook handler. The reason is that the shell builds and caches a list of registered copy hook handlers the first time copy hook handlers are called in a process. Once the list is created, there is no mechanism for updating or flushing the cache other than terminating the process. The best option that we can offer at this point is to restart the explorer.exe process or reboot the system after the copy hook handler is registered.

Please try these samples and let me know if they work for you.

I'm working on the other code sample requests now...

As we are in the beginning of providing the code sample request service, your feedback is really important to us, so that I can prove to my managers that it's a valuable service for customers, and it's a right thing for my managers to invest. Our feedback alias is: Thanks Jialiang Ge

ylangisc wrote Dec 20, 2010 at 9:46 AM

Thanks Jialiang, just read through the README. A short question: Is the .NET 4 Client Profile sufficient on a target machine to run the shell extension?

nerdfactor wrote Dec 20, 2010 at 10:31 AM

looks great. thank you very much Jialiang

seguso wrote Feb 7, 2011 at 10:59 AM

Hi, unfortunately this approach only works for folders. Does someone have any idea how to do the same for files? more precisely, how to detect when the user tries to move a file with Explorer (e.g. by choosing "paste" or by pressing CTRL+v) ? after detecting it, how to bypass the standard Explorer move file progress dialog and use your own file move dialog instead? Thank you very much for any hint.

HarisMunawar wrote Feb 26, 2011 at 9:11 AM

Hi, Jialiang,
I have downloaded the ICopyhook sample and registered it, it gets registered with appropriate entries, but no matter how I try, the CopyCallback never gets called, What could be the issue ?

HarisMunawar wrote Feb 26, 2011 at 11:56 AM

Hello Jialiang,
I have tried the ICopyHook code, the dll gets registered but no matter how I try the CopyCallback never gets called. What could be the issue?, the registry entry for Directory>shellex>CopyHandlers is there. Really stucked in there.


wrote Feb 22, 2013 at 3:00 AM

nookie wrote Aug 14, 2014 at 3:27 PM

Can someone send me the C# and C++ code, the links posted above are not working, i really appreciated, my email address is:

wrote Aug 14, 2014 at 3:33 PM