0

How to add an application into context menu for any user using c# code. I used this solution.

RegistryKey _key = Registry.ClassesRoot.OpenSubKey($"HKEY_CLASSES_ROOT\\Directory\\Background\\shell", true);
RegistryKey newkey = _key.CreateSubKey("Use Virtual Printer");

RegistryKey subNewkey = newkey.CreateSubKey("Command");
subNewkey.SetValue("", "C:\\yourApplication.exe");
subNewkey.Close();

newkey.Close();
_key.Close();

But I got Null Reference Exception in second line.

Kols
  • 3,641
  • 2
  • 34
  • 42

0 Answers0