[英]Windows Explorer right click context menu for files and folders
my question is similar into this , but that didn't gave all info I need, or I didn't understand that very well. 我的问题与此类似,但是没有提供我需要的所有信息,或者我不太了解。
I want that in file context menu there would be option to notify my app. 我希望在文件上下文菜单中可以选择通知我的应用程序。
I added keys: 我添加了键:
HKLM/SOFTWARE/Classes/*/shell/MyApp/command::"C:\\path\\test.exe" "%1"
HKLM/SOFTWARE/Classes/Folder/shell/MyApp/command::"C:\\path\\test.exe" "%1"
Code of test: 测试代码:
#include <iostream>
int main(int argc, char *argv[])
{
for (int i = 1; i < argc; ++i)
std::cout << argv[i] << "\r\n";
system("pause");
return 0;
}
This works fine, but... If I mark a few files/folders and right click and select my added option, many test apps launches. 这很好,但是......如果我标记了几个文件/文件夹并右键单击并选择我添加的选项,则会启动许多测试应用程序。
This is not the behaviour I want, I want that all paths would be passed into single instance of my app as list of argv
's, does anyone knows how to do that? 这不是我想要的行为,我希望所有路径都会作为
argv
的列表传递到我的应用程序的单个实例中,有谁知道如何做到这一点?
BTW. BTW。 I'm coding with
C++
but I think it isn't matter as it is business with Windows shell. 我使用
C++
编码,但我认为这与Windows shell的业务无关。
Thanks. 谢谢。
I think the right way is to write ContextMenuHandler and register it as shell extension. 我认为正确的方法是编写ContextMenuHandler并将其注册为shell扩展。
You can find lot of samples like here , here or here 你可以在这里 , 这里或这里找到很多样品
Context menu handlers are registered under key 上下文菜单处理程序在密钥下注册
HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers
There are similar questions on SO already: SO上也有类似的问题:
How to pass in multiple file/folder paths via a right-click event (verb) to an executable? 如何通过右键单击事件(动词)将多个文件/文件夹路径传递给可执行文件?
How to Pass MULTIPLE filenames to a Context Menu Shell Command? 如何将MULTIPLE文件名传递给Context Menu Shell命令?
Windows context menu for multiple files [C++] 多个文件的Windows上下文菜单[C ++]
Taking multiple files (arguments) from Windows shell context menu on C# 从C#上的Windows shell上下文菜单中获取多个文件(参数)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.