Why does the following code return NULL for shellValue
?
string shellValue;
RegistryKey shellKey = Registry.LocalMachine;
You are actually getting this subkey "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell". This is because some keys are redirected by WOW64. Check this for more info.
Try the following:
string shellValue;
RegistryKey shellKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);;
shellKey = shellKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true);
shellValue = shellKey.GetValue("Shell") as string;