How add context menu item to Windows Explorer for folders
I have found out how to add right-click context menu items to files on Windows Explorer, by adding keys to the registry. Ie I can right-click on a file in Explorer and run a custom app against that file.
I would like to do the same for a folder and have not found a way to do that (yet). I see articles on creating/writing custom context menu handlers, but I would rather not go there.
I have found an article here on how to add cascading context menu items to the Desktop and to the "Computer" in Explorer, but this does not work for any folder.
I would like to be able to add my custom app to the context menu and have it work on both files and folders. Is there a way to do this without writing a context menu handler?
Context menu for right click on folders in left panel of Windows Explorer or on background of a directory in right panel:
Context menu for right click on folders in right panel of Windows Explorer:
Context menu for any file:
In all cases:
More customization:
icon
for key created at step 1 with value matching an icon resource path. You can also provide an integer arguments to specify which icon to use. Example: %SystemRoot%System32shell32.dll,3
Extended
for key created at step 1 Position
with one of: Top
, Bottom
I found the solution in the below article, which describes how to do this via the registry for files, as well as for folders:
The following two articles provided additional info and options:
I went back and also answered this in another topic since there doesn't appear to be much on this question specifically.
I found the simplest way was to add a String Value to the key called "AppliesTo" and set its value to "under:{path}"
In my example, I want it to only look in the T Drive, so my String value is "AppliesTo":"under:T:".
In C#, this is easily accomplished with the following:
RegistryKey _key = Registry.ClassesRoot.OpenSubKey("FolderShell", true);
RegistryKey newkey = _key.CreateSubKey("My Menu Item");
newkey.SetValue("AppliesTo", "under:T:");
RegistryKey subNewkey = newkey.CreateSubKey("Command");
subNewkey.SetValue("", "C:yourApplication.exe");
subNewkey.Close();
newkey.Close();
_key.Close();
链接地址: http://www.djcxy.com/p/57386.html
上一篇: 如何打开任何窗口的上下文菜单?