Tutorial :How to add new items to right-click event on Folders and Files in Windows?



Question:

I did google couple of tutorials on google.

I am able to add right-click menu item to a FOLDER by doing this:

[HKEY_CLASSES_ROOT\Directory\shell\Command]  @="TestRightClick:"    [HKEY_CLASSES_ROOT\Directory\shell\Command\Command]  @="myExecutable.exe %L"  

I need to add this to a FILE as well.

1) Where do I add it in the registry?

2) And how do I pass parameters to my executable in case if I am selecting multiple files?

Related:

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


Solution:1

  1. Files have context menus by extension. Add your Command registry keys to the appropriate extension or HKEY_CLASSES_ROOT\* to affect all files.
  2. You can use %1 to pass the filename to the application (much like you've indicated with %L above). If you select multiple files, each will be called separately, as if you right-clicked each one individually.

I'm not aware of any easy way to pass multiple items from a right-click context menu to one executable instance.


Solution:2

The key word you're looking for is 'verbs' or 'handlers' not 'events'.

Context menu verbs for particular file extensions can be placed under the ProgID for the file type, the Perceived Type key (if the file type has a perceived type), the AllFileSystemObjects key, or the Base Class Key (*).

Note that writing to these keys in the HKEY_CLASSES_ROOT hive will redirect the writes to HKEY_LOCAL_MACHINE\Software\Classes, and will require elevated privileges. If you write to the HKEY_CURRENT_USER\Software\Classes tree, you can do this with standard user rights.

It's up to you to handle a scenario where multiple files are selected. One instance of your application will be launched per file you have selected. You can solve this by checking if another instance of your application is running, and using Inter-Process Communication to notify the existing instance that other extensions have been selected.

On MSDN, be sure to read


Solution:3

You can do it with my program singleinstance. No shell extensions involved.

Windows Registry Editor Version 5.00    [HKEY_CLASSES_ROOT\SystemFileAssociations\.txt\Shell\p4merge]  "MultiSelectModel"="Player"    [HKEY_CLASSES_ROOT\SystemFileAssociations\.txt\Shell\p4merge\Command]  @="\"d:\\singleinstance.exe\" %1 \"C:\\Program Files\\Perforce\\p4merge.exe\" $files --si-timeout 400"  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »