如何实现在下降目标的CSHARP应用程序并注册文件类型? [英] How to implement IDropTarget in an CSharp Application and register it for file types?
问题描述
我实现在C#这适用于文件的小工具。
因为我懒我要注册我就在注册表中的文件类型的工具,能够简单地从资源管理器中打开我的所有文件。
目前我使用 HCR \ MyFile的\壳\开放\命令
与%1$ c指定调用命令行来我的节目$ C>当前文件。
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.
这很好地满足单个文件,也选择多个文件时oviously没有。
我发现我的应用程序应实施 IDropTraget
来获得多个文件,但我不知道如何做到这一点。
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.
如何到我的csharp的应用程序实施 IDropTraget
?
How to my CSharp "application" implement IDropTraget
?
如何我再注册正确地把它称为文件类型我在Windows注册表中的应用程序?
How to I then register my application in the windows registry for the file types correctly to get it called?
我是比较新的,整个COM的东西。我用了好几次了,但我从来没有看到我自己写了一个COM类。 有一个例子或教程? (我搜索,但一无所获,至少我承认没有在这个方向上)
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)
谢谢!
推荐答案
如果您的应用程序使用Windows窗体,任何一类从Control派生可以AllowDrop属性设置为true和处理D&放大器; D(几乎)自动
If your application uses Windows Forms, any class deriving from Control can set the AllowDrop property to true and handle D&D (almost) automatically.
在这里看到类似:拖放文件从Windows资源管理器到Windows表
否则,你仍然可以重新使用Windows窗体实现在一个较低的水平下降目标被定义如下:的 IDropTaget
Otherwise, you can still reuse Windows forms implementation at a lower level as IDropTarget is defined here: IDropTaget
这篇关于如何实现在下降目标的CSHARP应用程序并注册文件类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!