string keyPath = @"Software\***\***"; string valueName = "ValueName"; using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(keyPath)) { if (key != null) { object value = key.GetValue(valueName); if (value != null) { Console.WriteLine("Registry Value: " + value.ToString()); } else { Console.WriteLine("Registry Value not found."); } } else { Console.WriteLine("Registry Key not found."); }
if (key != null) { //string[] valueNames = key.GetValueNames(); valueNames = key.GetValueNames(); if (valueNames.Length > 0) { Console.WriteLine("Values in Registry Key:"); foreach (string valueName in valueNames) { object value = key.GetValue(valueName); Console.WriteLine($"{valueName}: {value}"); } } else { Console.WriteLine("No values found in the Registry Key."); } } else { Console.WriteLine("Registry Key not found."); }
标签:Console,key,C#,valueName,value,搜索,Registry,WriteLine,注册表 From: https://www.cnblogs.com/CS-ComputerScience/p/17798397.html