Sign in to follow this  
Followers 0
wraithdu

Windows Drag and Drop Handler Shell Extension

19 posts in this topic

I'm writing a drag and drop handler shell extension and I would like to be able to get the process from which the drag operation originated. So if you dropped from a 3rd party file manager onto the desktop for example, I'd like to be able to get the PID of the source application (the file manager). Is this possible? So far I'm able to get the destination PID from the window handle of the context menu, but this is not useful for my purpose. Any ideas?

Share this post


Link to post
Share on other sites



It would help if we had a little background. Are you using AutoIt? C++? .Net? Java?

Share this post


Link to post
Share on other sites

Sorry: C++, VS 2010, uses ATL, but not MFC.

Share this post


Link to post
Share on other sites

I don't use ATL and am having difficulty finding documentation on it. Stupid common words.

Share this post


Link to post
Share on other sites

The ATL part isn't really important, but yeah, I'm having the same problem finding any information on it. The best I've found was in the source for SuperCopier where they enumerate the available clipboard formats, looking for one that is used exclusively by explorer. It works for identifying explorer as the source of the drop, but that's about all.

Essentially I'm writing an extension to become the default copy/move handler for the system, even on left button drag/drops. However I think this will mess up certain apps like 7-zip, so I want to try and filter the interception. I was hoping for a better solution than SC's, but I've come up empty so far.

Share this post


Link to post
Share on other sites

Have you already looked at TeraCopy?

Share this post


Link to post
Share on other sites

I have... in fact I'm trying to build similar functionality for FastCopy. TeraCopy does a few things I don't like. It screws up permissions sometimes when moving files on the same volume, resulting in files/folders with the lock icon on Win7. It also doesn't have as many options as FastCopy does for what is copied. I'd love to see Tera's source to see how they do it, but alas no joy there.

Share this post


Link to post
Share on other sites

I don't doubt that at all.

Share this post


Link to post
Share on other sites

I remember a microsoft dev saying that most explorer problems they got were caused by badly written shell-handers. They _hated_ them :huh2:

My response would have been: "Don't make writing shell extensions so arbitrarily complex."

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Any users of FastCopy out there that would like to give my shell extensions a try? Basic rundown:

- makes FastCopy the default copy/move handler, works for drag and drop and Ctrl-C|X / Ctrl-V

- intercepts operations from Explorer and probably most 3rd party file managers, does not interfere with other apps like 7-zip

- bypass by holding the left Windows key, the Windows copy handler will be invoked instead

- FastCopy has a few different copy modes which can be configured by INI file

- set options for general FastCopy behavior in INI file

- default options are: /cmd=force_copy /auto_close

- both x86 and x64 versions

- built with VS2010, so you'll probably need the VC++ 2010 runtimes

If you have TeraCopy installed and want to try this, you'll probably have to completely uninstall TeraCopy, since the app does not properly remove the x64 registry entries via the options GUI (works ok for the x86 entries though). I have two extensions and an INI file - drop all three in the FastCopy installation directory, edit the INI for your preferred options (or delete it or leave the defaults), and register the two DLLs.

Let me know if interested, and I can send you the files.

Edited by wraithdu

Share this post


Link to post
Share on other sites

Note about the 7-zip problem:

I thought this was interesting once I figured out what was going wrong. When dragging out of 7-zip, 7-zip first unzips the files to a temp directory, then invokes the shell with the paths to the temp files. It waits for the shell operation to complete then deletes the temp files. In the case of intercepting the copy/move with FastCopy (same problem with TeraCopy or SuperCopier), once the extension invokes FastCopy it returns, which tells 7-zip everything is done even when it is not and 7-zip deletes the temp files before FastCopy can copy them. I tried to make the shell extension wait for FastCopy to finish via a call to WaitForSingleObject, but this actually freezes the ENTIRE shell until it returns. It's not noticeable for quick operations, but on a long unzip, then shell will think it has crashed and you'll get the "not responding" warning. So in the end I can make it works with apps like 7-zip, but the shell doesn't cooperate to make it practical.

Share this post


Link to post
Share on other sites

Have anyone experienced these issues with Explorer?

Win XP Gold

Explorer crashed before installing any 3rd party software.I have installed XP on many machines and I found it true. I used to test beta XP releases and the last was rock solid. The RTM was terrible as far as explorer was concerned. Solution: SP1+

Win 7 Gold

Explorer can cause all processes to become unresponsive. Reboot when happens, expect hanging OS. Shutdown Explorer and open Explorer may help with luck. Solution: Do not keep Explorer open. Close Explorer as soon as you can to avoid trouble. Solution: Avoid long term use.

Anyone else got solutions to work around the known Explorer problems?

Share this post


Link to post
Share on other sites

What do you mean by XP Gold and 7 Gold?

And what happened to Vista?

Share this post


Link to post
Share on other sites

http://en.wikipedia.org/wiki/Software_release_life_cycle#RTM

Share this post


Link to post
Share on other sites

@MHz

I'm curious what this at all has to do with my topic?

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Ok, that answers the name, but that doesn't explain the Vista-less-ness.

Edited by Richard Robertson

Share this post


Link to post
Share on other sites

Any users of FastCopy out there that would like to give my shell extensions a try? Basic rundown: - makes FastCopy the default copy/move handler, works for drag and drop and Ctrl-C|X / Ctrl-V - intercepts operations from Explorer and probably most 3rd party file managers, does not interfere with other apps like 7-zip - bypass by holding the left Windows key, the Windows copy handler will be invoked instead - FastCopy has a few different copy modes which can be configured by INI file - set options for general FastCopy behavior in INI file - default options are: /cmd=force_copy /auto_close - both x86 and x64 versions - built with VS2010, so you'll probably need the VC++ 2010 runtimes If you have TeraCopy installed and want to try this, you'll probably have to completely uninstall TeraCopy, since the app does not properly remove the x64 registry entries via the options GUI (works ok for the x86 entries though). I have two extensions and an INI file - drop all three in the FastCopy installation directory, edit the INI for your preferred options (or delete it or leave the defaults), and register the two DLLs. Let me know if interested, and I can send you the files.

This is not a new topic, but I would like to try your files to register Fastcopy as the default copy handler. Are you still working on this?

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

Ahoi,

is this available for download anywhere? Other copy utilities like Perigee make their own Move context-menu entry the default for drag & drop (optionally), but there doesn't seem to be a simple registry hack to make that possible for FastCopy. So it even after all this time your solution is still interesting.

Thanks in advance!

Edited by TimurBorn

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0