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

后端 未结 7 1504
庸人自扰
庸人自扰 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
             }
    

提交回复
热议问题