Windows资源管理器右击文件和文件夹的上下文菜单 [英] Windows Explorer right click context menu for files and folders

查看:2683
本文介绍了Windows资源管理器右击文件和文件夹的上下文菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题类似于,但是没有提供我需要的所有信息,或者我不太明白。



我想要



我添加了键:

 

code> HKLM / SOFTWARE / Classes / * / shell / MyApp / command:C:\\path\\ test.exe%1
HKLM / SOFTWARE / Folder / shell / MyApp / command:C:\\path\\ test.exe%1

测试代码:

  #include< iostream> 

int main(int argc,char * argv [])
{
for(int i = 1; i std :: cout<< argv [i]<< \r\\\
;
system(pause);
return 0;
}

这可以正常工作,但...如果我标记几个文件/文件夹并右键点击并选择我添加的选项,许多测试应用程序启动。



这不是我想要的行为,我想所有的路径将被传递到我的单个实例应用程序列为 argv ,是否有人知道如何做?



BTW。我用 C ++ 编码,但我认为这不是因为它是与Windows shell的业务。



感谢。

解决方案

我认为正确的方法是写 ContextMenuHandler 并注册为shell扩展。



你可以找到很多样例此处这里此处



上下文菜单处理程序已在

键下注册

  HKEY_CLASSES_ROOT\ * \shellex\ContextMenuHandlers 

SO已经:





如何将多个文件名传递到上下文菜单Shell命令?



多个文件的Windows上下文菜单[C ++]



从C#上的Windows shell上下文菜单中获取多个文件(参数) / p>

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?

BTW. I'm coding with C++ but I think it isn't matter as it is business with Windows shell.

Thanks.

解决方案

I think the right way is to write ContextMenuHandler and register it as shell extension.

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:

How to pass in multiple file/folder paths via a rigth-click event(verb) to an executable?

How to Pass MULTIPLE filenames to a Context Menu Shell Command?

Windows context menu for multiple files [C++]

Taking multiple files (arguments) from Windows shell context menu on C#

这篇关于Windows资源管理器右击文件和文件夹的上下文菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆