How to check if a registry value exists using C#?

后端 未结 7 1377
庸人自扰
庸人自扰 2020-12-08 13:28

How to check if a registry value exists by C# code? This is my code, I want to check if \'Start\' exists.

public static bool checkMachineType()
{
    Registr         


        
相关标签:
7条回答
  • 2020-12-08 13:58
      RegistryKey rkSubKey = Registry.CurrentUser.OpenSubKey(" Your Registry Key Location", false);
            if (rkSubKey == null)
            {
               // It doesn't exist
            }
            else
            {
               // It exists and do something if you want to
             }
    
    0 讨论(0)
提交回复
热议问题