There is a good example of how to loop through all the keys for a registry here:
https://stackoverflow.com/questions/1458653/iterate-through-registry-entries
Read about the Registry Key Class here:
https://docs.microsoft.com/en-us/dotnet/api/microsoft.win32.registrykey?view=netframework-4.7.2
There are multiple keys that deal with the right-click context menu.
For file items:
HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\
Some additional menu items for programs are stored at these locations:
HKEY_CLASSES_ROOT\*\shell
HKEY_CLASSES_ROOT\AllFileSystemObjects\ShellEx\ContextMenuHandlers
For folder items:
HKEY_CLASSES_ROOT\Folder\shellex\ContextMenuHandlers\
HKEY_CLASSES_ROOT\Directory\shell
For desktop items:
HKEY_CLASSES_ROOT\Directory\Background\shell
HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers
It is a simple thing to get a key and loop over all the subkeys.
using Microsoft.Win32;
public void EnumerateRegistryKeys()
{
RegistryKey key = Registry.<desired root here>.OpenSubKey("<desired key here>");
foreach (string subKeyName in key.GetSubKeyNames())
{
}
}
In the above code you must substitute your desired root and key for the text in angle brackets. For example:
RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"Folder\shellex\ContextMenuHandlers\");
NOTE: Reading the registry is pretty safe, but writing values to the registry can cause serious problems. Backup the registry before changing it.