注册表检查

public string result;
public string GetRegData(string regFatherPath, string Value1, string Value1Data, string Value2)
{
RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(regFatherPath, false);
if (key != null)
{
foreach (string keyName in key.GetSubKeyNames())
{
try
{
RegistryKey key2 = key.OpenSubKey(keyName, false);
if (key2.GetValue(Value1).ToString() == Value1Data)
{
result = key2.GetValue(Value2).ToString();
break;
}
}
catch { MessageBox.Show(Value1Data + " or " + Value2 + " is not exist."); }

}
return result;
}
else return "Fail";
}

原文地址:https://www.cnblogs.com/EthanSun/p/3126656.html