Registry Key Get Value returns NULL

前端 未结 1 365
迷失自我
迷失自我 2021-01-16 20:56

Why does the following code return NULL for shellValue?

        string shellValue;
        RegistryKey shellKey = Registry.LocalMachine;
                


        
1条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-16 21:40

    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;
    

    0 讨论(0)
提交回复
热议问题