2

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 multiple 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!

Knowleech
  • 1,013
  • 2
  • 9
  • 15

1 Answers1

2

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

Simon Mourier
  • 132,049
  • 21
  • 248
  • 298
  • Hi Simon, thanks for the answer, but what is missing is how do I then register my application for file types in the registry? – Knowleech Mar 21 '11 at 18:29
  • 1
    @3of4 - Here is a link on SO for this: http://stackoverflow.com/questions/69761/how-to-associate-a-file-extension-to-the-current-executable-in-c – Simon Mourier Mar 21 '11 at 20:05
  • I only find file associations using the normal open verbs there. This is what I am currently doing and what results in the problem I am having (each file will be opened in a separate process). I read somewhere that IDropTarget can be used to get multiple files into one process. But I think I will rephrase my question (after another round in google) and ask it again. Thanks for your help. – Knowleech Mar 23 '11 at 08:14