2

After putting a filedroplist on the clipboard – right clicking in windows explorer doesn’t give me the option to “create shortcut”. How do I get that?

Thanks.

ispiro
  • 26,556
  • 38
  • 136
  • 291
  • if you are asking how to programmatically create a shortcut: http://stackoverflow.com/questions/234231/creating-application-shortcut-in-a-directory/234543#234543 – IAbstract Aug 31 '11 at 20:39
  • @IAbstract No. I want to be able to put a filedroplist on the clipboard, then right click in windows explorer, and get an option to “create shortcut”. Just as if I did a ‘copy’ using windows explorer. – ispiro Aug 31 '11 at 20:43
  • What are you putting on the clipboard? How many files? – David Heffernan Aug 31 '11 at 21:07
  • @David Heffernan For now – one. – ispiro Aug 31 '11 at 21:13

2 Answers2

0

This won't work as you want it to. When you drag a file on your computer and release the right-mouse the clipboard is not involved. You can test this by opening notepad, writing some text and copying it, then create a shortcut on your computer through right-clicking and finally pasting the text back into notepad. When you do this you'll see the text is still there which means no file was place "over" it.

So there's nothing that you can do to the clipboard to change the "create shortcut here" meaning. The closest thing that you can do is to create a shortcut as @IAbstract said and copy that shortcut to the clipboard. The you'll be able to right-click and paste the shortcut. See this article for more Drag & drop of a dynamically created shortcut

Community
  • 1
  • 1
Chris Haas
  • 53,986
  • 12
  • 141
  • 274
  • I'm assuming that ispiro wants the context menu to offer "Paste as shortcut" – David Heffernan Aug 31 '11 at 21:12
  • @Chris Haas Not doing a drag. Try this: right click on a file. Click ‘copy’. Right click somewhere else. Click ‘paste shortcut’. – ispiro Aug 31 '11 at 21:17
  • Thanks @ispiro, that helps. There is a "create shortcut" command which was confusing. I couldn't find an example of anyone fully doing this in .Net but the post below outlines the basics in C. Ultimately you need to create a `CFSTR_SHELLIDLIST` structure and call `SetData` passing `Shell IDList Array` and your structure. Sounds simple but there's a lot of work involved which I unfortunately don't have time to get into, but maybe someone else here can. http://netez.com/2xExplorer/shellFAQ/adv_drag.html – Chris Haas Aug 31 '11 at 22:02
0

You need other formats present, particularly the OLE stuff.

Experimenting with a diagnostic mode of my app (ClipMate), I see that when you have copied a file to the clipboard, and then right-click on the windows desktop, the following formats are read from the clipboard:

Ole Private Data
DataObject
Preferred DropEffect
HDROP
Shell IDList Array

And then when you actually perform "paste shortcut", an additional format is pulled:

Shell Object Offsets

I was able to perform a "paste shortcut" without the Preferred DropEffect, so I think that's optional. I tested on Windows XP, SP3. YMMV with other platforms.

Chris Thornton
  • 15,620
  • 5
  • 37
  • 62