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