集成到Windows资源管理器上下文菜单

时间:2022-05-16 10:56:26

I want to write a small tool, that does the following:

我想写一个小工具,它的作用是:

When you right click on a file with a certain file-extension the Windows Explorer context menu shows an additional entry.

当你右键点击某个文件扩展的文件时,Windows资源管理器上下文菜单会显示一个额外的条目。

When you click this entry a certain EXE is launched with this file as one of its parameters.

当您单击此条目时,将以该文件作为其参数之一启动某个EXE。

I would like to use C#/.NET 2.0 for this. If it's not possible I could also do it with C++/Win32.

我想用c# /。NET 2.0。如果不可能,我也可以用c++ /Win32。

My questions are:

我的问题是:

  1. Is it possible with C# .NET 2.0?
  2. c#。net 2.0有可能吗?
  3. What are the necessary functions for integrating into the Windows Explorer context menu?
  4. 集成到Windows资源管理器上下文菜单的必要函数是什么?
  5. How can I make this permanent? (I don't want to relaunch this tool after every boot)
  6. 我怎样才能使它永久存在?(我不想在每次开机后重新启动这个工具)
  7. What do I have to take special care of? (different OS, security permissions, etc.)
  8. 我需要特别照顾什么?(不同的操作系统、安全权限等)

3 个解决方案

#1


24  

You will need to access the registry and add a key under root\\File\\shell or root\Folder\\shell, depending on which items you want the menu item visible on.

您将需要访问注册表并在根\文件\\shell或根\文件夹\shell中添加一个键,这取决于您希望菜单项显示在哪些项上。

Try this article at CodeProject, it's quite useful.

在CodeProject上试试这篇文章,它非常有用。

Edit: There's another article here which may be of help.

编辑:这里还有一篇文章可能会有所帮助。

#2


4  

All you need to do is add some stuff to the registry. So yes you can do this with .NET 2.0. Here is an example of how to add Edit with Notepad.

您需要做的就是向注册表添加一些东西。是的,你可以用。net 2。0。下面是如何使用记事本添加编辑的示例。

%1 is the selected file if I remember right.

%1是选中的文件,如果我没记错的话。

#3


3  

It is, incidentally, not supported to use .NET for shell extensions, due to the current inability to host multiple runtime versions in the same process (.NET 4 will lift this restriction).

顺便说一句,由于目前无法在同一进程中托管多个运行时版本(由于目前无法在同一进程中托管多个运行时版本,所以不支持将. net用于shell扩展)。NET 4将取消这个限制)。

Consider the case where you have two shell extensions; one for .NET 3.5, one for .NET 1. Which runtime will get loaded into your process? Well, it's more or less random--it depends which shell extension gets loaded first. Sometimes it might be the 2.0 runtime, sometimes it might be the 1.1 runtime.

考虑有两个shell扩展的情况;一个是。net 3.5,一个是。net 1。哪个运行时将加载到您的进程中?嗯,它或多或少是随机的——它取决于首先加载的shell扩展。有时可能是2.0运行时,有时可能是1.1运行时。

This is also an issue if a .NET program creates common file dialogs; your shell extension may or may not load, and may or may not run with the correct runtime version.

如果.NET程序创建公共文件对话框,这也是一个问题;您的shell扩展可以装入也可以不装入,也可以运行在正确的运行时版本中。

As such, if you go down the Shell extension route you should use native C++/COM/Win32.

因此,如果沿着Shell扩展路径,应该使用本机c++ / com win32。

#1


24  

You will need to access the registry and add a key under root\\File\\shell or root\Folder\\shell, depending on which items you want the menu item visible on.

您将需要访问注册表并在根\文件\\shell或根\文件夹\shell中添加一个键,这取决于您希望菜单项显示在哪些项上。

Try this article at CodeProject, it's quite useful.

在CodeProject上试试这篇文章,它非常有用。

Edit: There's another article here which may be of help.

编辑:这里还有一篇文章可能会有所帮助。

#2


4  

All you need to do is add some stuff to the registry. So yes you can do this with .NET 2.0. Here is an example of how to add Edit with Notepad.

您需要做的就是向注册表添加一些东西。是的,你可以用。net 2。0。下面是如何使用记事本添加编辑的示例。

%1 is the selected file if I remember right.

%1是选中的文件,如果我没记错的话。

#3


3  

It is, incidentally, not supported to use .NET for shell extensions, due to the current inability to host multiple runtime versions in the same process (.NET 4 will lift this restriction).

顺便说一句,由于目前无法在同一进程中托管多个运行时版本(由于目前无法在同一进程中托管多个运行时版本,所以不支持将. net用于shell扩展)。NET 4将取消这个限制)。

Consider the case where you have two shell extensions; one for .NET 3.5, one for .NET 1. Which runtime will get loaded into your process? Well, it's more or less random--it depends which shell extension gets loaded first. Sometimes it might be the 2.0 runtime, sometimes it might be the 1.1 runtime.

考虑有两个shell扩展的情况;一个是。net 3.5,一个是。net 1。哪个运行时将加载到您的进程中?嗯,它或多或少是随机的——它取决于首先加载的shell扩展。有时可能是2.0运行时,有时可能是1.1运行时。

This is also an issue if a .NET program creates common file dialogs; your shell extension may or may not load, and may or may not run with the correct runtime version.

如果.NET程序创建公共文件对话框,这也是一个问题;您的shell扩展可以装入也可以不装入,也可以运行在正确的运行时版本中。

As such, if you go down the Shell extension route you should use native C++/COM/Win32.

因此,如果沿着Shell扩展路径,应该使用本机c++ / com win32。