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#