Windows Explorer right click context menu for files and folders

萝らか妹 提交于 2019-11-29 22:06:22

问题


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.


回答1:


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 right-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#



来源:https://stackoverflow.com/questions/20740846/windows-explorer-right-click-context-menu-for-files-and-folders

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!