将文件关联到应用程序
我正在构建两个程序,一个文本编辑器和一个拉链,但是在这两个程序中我想将文件类型与它们关联,但我该怎么做呢?谢谢。
I'm building two programs, a text editor and a zipper, but in this two programs I want to associate a file type to they, but how can I do this? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要编辑注册表:http://support.microsoft.com/kb/257592
您可能需要使用 regedit 来查看以前的文件关联,以确保不会搞砸。
C# 注册表基础知识
You need to edit the registry: http://support.microsoft.com/kb/257592
You'll probably want to use regedit to see previous file associations, to make sure you don't mess up.
c# registry basics
我知道这是一个旧线程,但我认为您不应该像这样乱搞注册表。尤其是自从 ClickOnce 和其他部署向导已经实现了建立文件关联的内置功能以来。您可以在解决方案资源管理器 -> 中找到它项目属性->发布选项卡 ->选项按钮->文件关联选项卡。在这里,您可以使用自定义图标、文件描述和程序标识来注册文件类型。
如果您想先行一步,也可以使用单实例应用程序来实现这一点。我在我的网站上的教程项目中做到了这一点:
DrawIt
在该项目中,我在第一个实例中设置一个 TCP 监听器,在第二个、第三个实例中,...我连接一个 TCP 客户端并将 ActivationArguments 发送到第一个实例。
最重要的代码块位于文件 Program.cs 中,并在 Hoofdscherm.cs 中 void Start_server。
I know this is an old thread, but I don't think you should be messing around with the registry like that. Especially not since ClickOnce and other deployment wizards have implemented a built-in capability to make a file-association. You can find this in Solution Explorer -> Project Properties -> Publish tab -> Options button -> File-associations tab. Here you have the ability to register a file-type using a custom icon, description of the file, and a program identification.
If you want to take a step ahead, you can do this with Single-instance applications as well. I did this in a tutorial project on my website:
DrawIt
In the project I'm setting up a TCP-listener in the first instance and in the second, third, ... instance I connect a TCP-client and send the ActivationArguments to the first one.
The most important code blocks are in the file Program.cs and void Start_server in Hoofdscherm.cs.