static public string ReadFromRegistry(RegistryKey RegHive, string RegPath, string KeyName, string DefaultValue)
{
string[] regStrings;
string result = "";
regStrings = RegPath.Split('\\');
//First item of array will be the base key, so be carefull iterating below
RegistryKey[] RegKey = new RegistryKey[regStrings.Length + 1];
RegKey[0] = RegHive;
for( int i = 0; i < regStrings.Length; i++ )
{
RegKey[i + 1] = RegKey[i].OpenSubKey(regStrings[i]);
if (i == regStrings.Length - 1 )
{
result = (string)RegKey[i + 1].GetValue(KeyName, DefaultValue);
}
}
return result;
}