4
Vote

C# ICopyHook implementation based on CSShellExt*

description

Hi All,
 
Referring to my discussion entry (http://1code.codeplex.com/Thread/View.aspx?ThreadId=233347) 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 http://winscp.net/eng/docs/dragext for more details why one need it.
 
Regards,
Yves

comments

Jialiang wrote Nov 10, 2010 at 6:00 AM

Hello

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 7:44 AM

Just curious if this request is one the mentioned 5 which are already in development (http://blogs.msdn.com/b/codefx/archive/2010/11/08/please-join-us-to-vote-for-code-samples-topics-and-become-a-star-of-the-month-episode-1.aspx)?

Great initiative btw!

Yves

ylangisc wrote Nov 23, 2010 at 9: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 3:28 PM

nerdfactor wrote Dec 14, 2010 at 10: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 1:10 PM

hello

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 1:29 PM

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

ylangisc wrote Dec 15, 2010 at 1:30 PM

Thanks Jialiang, your effort is very much appreciated! Yves

Jialiang wrote Dec 20, 2010 at 8:24 AM

Hello

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

CSShellExtCopyHookHandler (the .NET 4 C# version) http://1code.codeplex.com/releases/view/57436#DownloadId=189054
VBShellExtCopyHookHandler (the .NET 4 VB version) http://1code.codeplex.com/releases/view/57436#DownloadId=189055
CppShellExtCopyHookHandler (the C++ version) http://1code.codeplex.com/releases/view/57436#DownloadId=189053

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: onecode@microsoft.com. Thanks Jialiang Ge

ylangisc wrote Dec 20, 2010 at 8: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 9:31 AM

looks great. thank you very much Jialiang

seguso wrote Feb 7, 2011 at 9: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 8: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 ?
Regards,
Haris

HarisMunawar wrote Feb 26, 2011 at 10: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.

Regards,
Haris

wrote Feb 22, 2013 at 2:00 AM

nookie wrote Aug 14, 2014 at 2:27 PM

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

wrote Aug 14, 2014 at 2:33 PM