壳牌集成在Windows中的特定文件类型与C# [英] Shell Integrate in Windows for a Specific File Type With C#

查看:123
本文介绍了壳牌集成在Windows中的特定文件类型与C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我搜索了如何整合外壳您的应用程序(它添加到右键菜单)用C#指导,但我找不到怎么办,只有一个特定的文件类型。我知道这是可能的,因为WinRAR的做到这一点。所以,我该怎么办呢?

So I searched for a guide of how to shell integrate your application (add it to the right click menu) with C#, but I couldn't find how to do that only for a specific file type. I know it is possible because WinRar does that. So how can I do that?

推荐答案

通常有两种杂交方法可以实现这一点。

There are usually two-ish ways you can implement this.


  1. 注册表键 - 你可以写HKEY_CLASSES_ROOT下的键和值。如果你看一下那个蜂巢你会看到电脑的扩展。看的细节这文章对键和值。一些简单的像一个选项,您的应用程序可以在这儿开 .myfile 类型。这里是一个文件关联实例

  1. Registry Keys - You can write keys and values under HKEY_CLASSES_ROOT. If you look at that hive you'll see the extensions on your pc. Look at this article for the details about the keys and values. Something simple like an option to open .myfile types with your application is possible here. Here is a File Association Example

外壳扩展(COM中写的):在这里,你可以做更复杂的东西一样的处理程序。他们将被Windows被调用,所以你可以做这样的事情搽菜单,或添加自定义操作时,文件右键单击。还有更多的在这里比的文件,你甚至可以添加属性表和自定义工具提示。

Shell Extensions (Written in COM) : Here you can do more complicated stuff like Handlers. They will get called by Windows so you can do things like paint on menus, or add custom actions when a file is right-clicked. There is more to it here than files, you can even add property sheets and custom tooltips.

您会发现一些关于不使用.NET编写外壳处理**。这仅适用于老年 .NET版本。 它的一切ok与.NET4。

You will find some talk about not using .NET to write a Shell Handler**. This applies only to older versions of .NET. Its all ok with .NET4.

这文章应该帮助你用的在.NET4 上下文菜单处理程序

This article should help you with a Context Menu Handler in .NET4

**为什么它不建议:

** Why was it not recommend:

当你写一个shell处理程序,它就会由主机进程(通常是Windows资源管理器)呼吁,但还搞什么FileOpenDialogs和FolderBrowser对话框。所以,如果你在.NET 2.0写了一个外壳扩展,以及.NET 1.1的应用程序称为打开文件对话框,然后你的.NET 2.0的外壳处理程序将被调用到你的.NET 1.1应用程序,它有一个更老CLR会出现问题而且会有版本冲突。

When you write a shell handler, it gets called by the host process (typically windows explorer), but also things like FileOpenDialogs and FolderBrowser dialogs. So a problem would occur if you wrote a shell extension in .NET 2.0, and a .NET 1.1 app called a File Open Dialog and then your .NET 2.0 shell handler would be called into and your .NET 1.1 app which has an older CLR and there would be version conflict.

所以,我很高兴地发现了这终于已经在.NET 4莫名其妙定=)

So I'm pleased to have found out finally this has been fixed somehow in .NET 4 =)

这篇关于壳牌集成在Windows中的特定文件类型与C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆