The most likely cause is that you're running a 32-bit application on a 64-bit OS:
c# - OpenSubKey() returns null for a registry key that I can see in regedit.exe - Stack Overflow[
^]
By default, you'll be looking in
HKLM\Software\Wow6432Node
, thanks to the registry redirector:
Registry Redirector (Windows)[
^]
Assuming you're using .NET 4.0 or later, you'll need to specify the registry view:
using (var hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64))
using (var key = hklm.OpenSubKey(@"SOFTWARE\PenMount Windows Universal Driver"))
{
}
If you're using an earlier version, you'll need some P/Invoke calls instead:
How to read the 64 bit registry from a 32 bit application or vice versa | Rhyous[
^]