简体   繁体   English

如何扩展Windows资源管理器的行为单击或扩展外壳行为

[英]How Can I extend the Behaviour of Windows Explorer Click or Extending the Shell Behaviour

Is there any way I can extend or modify the behavior of Windows Explorer click? 有什么方法可以扩展或修改Windows资源管理器单击的行为?

For example, I want to modify the the click event. 例如,我要修改click事件。 On clicking a drive, I should be able to connect to an FTP server instead of opening the drive. 单击驱动器后,我应该能够连接到FTP服务器,而不必打开驱动器。 The drive will be a mounted drive. 该驱动器将是已安装的驱动器。

So what I want to do is modify the default behavior of Windows Explorer Click or Extending the Behaviour of Shell (I'm not sure if this belongs to shell extension). 因此,我想做的是修改Windows资源管理器的默认行为。单击“单击或扩展外壳程序的行为”(我不确定这是否属于外壳程序扩展名)。

Hmya, this is quite a bit beyond "click". 嗯,这远远超出了“点击”范围。 You'd have to write a shell extension. 您必须编写一个shell扩展。 Doing this in C# was quite off limits until .NET 4.0 because of the CLR version injection problem. 由于CLR版本注入问题,在.NET 4.0之前,用C#进行此操作是完全不可行的。 Unmanaged programs (say, Notepad) would get the CLR injected in them when they use a shell dialog, like FolderBrowser or OpenFileDialog. 当非托管程序(例如,记事本)使用诸如ShellBrowser或OpenFileDialog之类的shell对话框时,将在其中注入CLR。 Which could cause subsequent code to fail that requires another version of the CLR. 这可能会导致后续代码失败,从而需要其他版本的CLR。 That's solved, CLR 4.0 supports in-memory side-by-side operation of multiple CLR versions. 解决了这一问题,CLR 4.0支持多个CLR版本的内存并行操作。

What isn't solved is the complexity of the code you'd need to write. 无法解决的是您需要编写的代码的复杂性。 Shell extensions require COM code. Shell扩展名需要COM代码。 The hard kind, interfaces that derive from IUnknown. 从IUnknown派生的硬类型接口。 To even get started, you need to write masses of declarations for the COM interfaces. 为了开始使用,您需要为COM接口编写大量的声明。 You can't get them out of the SDK declarations, they are only usable by a C++ program. 您不能将它们从SDK声明中删除,它们只能由C ++程序使用。 And it is very error prone, C# doesn't support multiple inheritance, the feature you'd need to declare COM interfaces that are derived from other interfaces. 而且它很容易出错,C#不支持多重继承,这是您需要声明从其他接口派生的COM接口的功能。

Last but not least, debugging this kind of code is a nightmare. 最后但并非最不重要的一点是,调试此类代码是一场噩梦。 This is an essential Windows process you're tinkering with. 这是您要修补的Windows必不可少的过程。 Making a mistake leaves you with an unusable shell. 犯错误将使您无法使用外壳。 Rebooting starts that same borked shell. 重新启动会启动相同的中断外壳。

Well, black-belt skills required. 好吧,需要黑带技能。 I imagined that the availability of .NET 4.0 should have jump-started some projects that provide friendly managed wrappers. 我以为.NET 4.0的可用性应该已经启动了一些提供友好的托管包装程序的项目。 I just haven't seen any yet. 我还没看过。 Take that as a sign as well. 也以它为标志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM