简体   繁体   English

我在资源管理器中有一个上下文菜单项,现在如何最好地在文件上调用进程?

[英]I have a context menu item in Explorer, now how is it best to call my process on the file?

I have added a context menu item in Explorer. 我在资源管理器中添加了上下文菜单项。 I added it via a registry modification. 我是通过注册表修改添加的。 On right click on a file, I want to call my compression algo on it. 在文件上单击鼠标右键,我要在其上调用压缩算法。

At the moment, this compression feature is a method in a C# class library. 目前,此压缩功能是C#类库中的一种方法。 I have a basic Visual Studio 2010 solution containing this class library (1 class, 1 resource file), and an install Wizard project (very simple). 我有一个基本的Visual Studio 2010解决方案,其中包含此类库(1个类,1个资源文件)和一个安装向导项目(非常简单)。 At the moment, when I run "install" on this install wizard, I manage to have a DLL for the class library, and my resource file dropped at the location given at install. 此刻,当我在此安装向导上运行“安装”时,我设法为类库提供了一个DLL,并且我的资源文件被放置在安装时给定的位置。

From my registry entry, I am able to run a command. 从注册表项中,我可以运行命令。 At the moment I run notepad.exe on the right clicked file. 目前,我在右键单击的文件上运行notepad.exe。

1. Can I somehow register my DLL to call its functions ? 1.我可以以某种方式注册我的DLL来调用其功能吗? (I'm not looking at any shell extension, and I had the impression there was something simpler) (我没有看任何shell扩展,给人的印象是简单一些)

2. Otherwise I don't mind creating an .exe with a console application or such. 2.否则,我不介意使用控制台应用程序等创建.exe。 If I do so, will I get the filepath from the args parameter of my Main(string[] args) ? 如果这样做,是否可以从Main(string [] args)的args参数获取文件路径?

3. In option 2, where do i need to reference my .exe ? 3.在选项2中,我需要在哪里引用我的.exe? I don't see Notepad++ anywhere in my environment variables and still it is callable without specifying its path. 我在环境变量的任何位置都看不到Notepad ++,但仍可以在不指定其路径的情况下调用它。

Thank you guys ! 感谢大伙们 !

1. With caveats; 1.注意事项; http://blogs.msdn.com/b/codefx/archive/2010/09/14/writing-windows-shell-extension-with-net-framework-4-c-vb-net-part-1.aspx http://blogs.msdn.com/b/codefx/archive/2010/09/14/writing-windows-shell-extension-with-net-framework-4-c-vb-net-part-1.aspx

2 & 3 If you use the simpler approach of associating an executable simply: 2&3如果您使用简单的方法来关联可执行文件,则只需:

your_file_type\\shell\\open\\command (default) = "c:\\yourapp.exe" "%1"

and your app will recieve the command line. 然后您的应用将收到命令行。

暂无
暂无

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

相关问题 在 UWP 中的 Windows Explorer 的文件上下文中添加上下文菜单项 - Add context menu item to Windows Explorer's File context in UWP 单击上下文菜单项时,将上下文菜单项插入资源管理器并传递完整文件名 - Insert a Context menu Item to Explorer and pass the Full File Name when Context Menu item is Clicked 如何在Windows资源管理器的“新建”上下文菜单中添加一个项目以打开一个窗口? - How do I add an item to Windows Explorer's “New” context menu which opens a window? Visual Studio AddIn:如何将项目特定命令添加到解决方案资源管理器上下文菜单 - Visual Studio AddIn: How do I Add Item Specific Commands to the Solution Explorer Context Menu 如何将自己的项目添加到文本框的默认上下文菜单(剪切,复制,粘贴, <my item> )。 - How can I add my own item to the default context menu of a textbox (cut, copy, paste, <my item>). Windows资源管理器上下文菜单上的InfoTip - InfoTip on Windows explorer context menu item 将上下文菜单项添加到Windows资源管理器 - Adding a context menu item to windows explorer C#将上下文菜单项添加到Windows资源管理器中的所有文件类型 - C# adding context menu item to windows explorer for all file types 如何在Windows 10的“快速访问”部分添加文件夹? 或如何为文件夹调用Windows资源管理器上下文菜单选项? - How to add a folder to the “Quick Access” section in windows 10? OR How to call windows explorer context menu option for a folder? 如何在应用程序中托管资源管理器上下文菜单? - How to host explorer context menu in app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM