简体   繁体   English

如何使用 .NET6 扩展 Windows 资源管理器上下文菜单?

[英]How to extend the Windows Explorer Context Menu with .NET6?

There is a good way to interact with the Windows Explorer shell for .NET Framework (see https://github.com/dwmkerr/sharpshell#shell-context-menus ).有一种与 Windows Explorer shell for .NET Framework 交互的好方法(参见https://github.com/dwmkerr/sharpshell#shell-context-menus )。

Is that approach from ShareShell (interacting through COM servers) still the correct way for a new .NET6 or .NET7 application targeting Windows 10 and Windows 11 only? ShareShell 的这种方法(通过 COM 服务器进行交互)是否仍然是仅针对 Windows 10 和 Windows 11 的新 .NET6 或 .NET7 应用程序的正确方法?

Looking at https://learn.microsoft.com/en-us/windows/win32/shell/context-menu , is it the right entry point to implement?查看https://learn.microsoft.com/en-us/windows/win32/shell/context-menu ,它是实施的正确入口点吗?

I didn't found any nuget package or other site describing a good solution for the current .NET and Windows platforms.我没有找到任何 nuget package 或其他网站描述当前 .NET 和 Windows 平台的良好解决方案。

I would prefer a solution without COM if there is one because my knowledge related to COM is limited.如果有的话,我更喜欢没有 COM 的解决方案,因为我对 COM 的了解有限。

A classic static verb can be added without writing code, just add it to the registry:一个经典的static动词不用写代码也可以添加,直接添加到注册表即可:

HKCR\.myext\=myextfile
HKCR\myextfile\shell\open\command\="c:\apps\myapp.exe" "%1"

To appear in the new menu in Windows 11 you have to implement the IExplorerCommand COM object and you have to be a packaged app with identity.要出现在 Windows 11 中的新菜单中,您必须实施IExplorerCommand COM object 并且您必须是具有标识的打包应用程序。

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

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