简体   繁体   English

Windows资源管理器右键单击文件和文件夹的上下文菜单

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

相关问题 如何显示 Windows 资源管理器上下文(右键单击)菜单? - How to show Windows Explorer context (right click) menu? Windows资源管理器上下文菜单 - Windows Explorer Context Menu 以编程方式为多个文件调用Windows shell菜单(与在资源管理器中右键单击相同) - Calling Windows shell menu (same as right-click in Explorer) for multiple files programmatically 如何将我的程序添加到 macOS 的文件和文件夹右键菜单? - How to add my program to macOS right click menu for files and folders? 如何添加Windows右键单击上下文菜单项? - How can I add Windows right click context menu items? 如何在 QGraphicsView 中为右键单击创建上下文菜单 - How to create a context menu for right click in QGraphicsView 如何在列表框上右键单击创建上下文菜单? - How to create a context menu on listbox right click? 电子内部或外部方法来创建自己的右键单击上下文菜单-Windows - Electron internal or external method to create own right click context menu - Windows 将应用程序的选项添加到Windows资源管理器上下文菜单 - Adding options for your application to the Windows Explorer context menu 如何显示不同文件夹中多个文件的系统上下文菜单? - How to display system context menu for multiple files in different folders?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM