How to implement IDropTarget in an CSharp Application and register it for file types?
I'm implementing a small tool in C# which works on files.
Because I'm lazy I want to register my tool on the file types in the registry to be able to simply open all my files from the explorer.
Currently I am using HCR\MyFile\shell\open\command
to specify the calling command line to my program with "%1"
for the current file.
This works fine for single files, but oviously not when selecting mu开发者_运维技巧ltiple files.
I found out that my application should implement IDropTraget
to get multiple files, but I don't know how to do this.
How to my CSharp "application" implement IDropTraget
?
How to I then register my application in the windows registry for the file types correctly to get it called?
I am relatively new to the whole COM stuff. I "used" it several times now, but I never wrote a COM-class by my own. Is there an example or tutorial? (I searched, but found nothing, at least I recognized nothing in this direction)
Thanks!
If your application uses Windows Forms, any class deriving from Control can set the AllowDrop property to true and handle D&D (almost) automatically.
See here for something similar: Drag and Drop files from Windows Explorer to Windows Form
Otherwise, you can still reuse Windows forms implementation at a lower level as IDropTarget is defined here: IDropTaget
精彩评论