[英]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.