c# – Windows File Explorer extension for creating url shortcuts – Part 2
In previous post we stated extension for creating url shortcuts. Now it is time to create actual file explorer menu items and get the basics working. First let’s create small class what will deal with needed registry entries. Creating contect menu items is quite simple, just two entries in registry.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
using Microsoft.Win32; using System.Windows.Forms; namespace UrlExtension { public class UriExtensionUtils { public static void AddOption_ContextMenu() { RegistryKey _key = Registry.ClassesRoot.OpenSubKey("Directory\\Background\\Shell", true); RegistryKey newkey = _key.CreateSubKey("Add URL Shortcut"); RegistryKey subNewkey = newkey.CreateSubKey("command"); string appDirectory = Application.ExecutablePath.Replace("\\", "\\\\"); subNewkey.SetValue("", appDirectory); subNewkey.Close(); newkey.Close(); _key.Close(); } public static void RemoveOption_ContextMenu() { RegistryKey _key = Registry.ClassesRoot.OpenSubKey("Directory\\Background\\Shell\\", true); _key.DeleteSubKey("Add URL Shortcut"); _key.Close(); } } } |
To handle registration and… Read More »