public void OpenSubKeyTest() { WowRegistryKey key = WowRegistry.LocalMachine.OpenSubKey(@"SOFTWARE\Oracle"); Assert.IsNotNull(key); WowRegistryKey subkey = key.OpenSubKey("KEY_OraDb11g_home1"); Assert.IsNotNull(subkey); }
// Different versions of Oracle place the ODP.NET key in different locations // under the HKLM\SOFTWARE\ORACLE key. So recurse down the subtree until it // is found. private static bool HasOdpNetKey(WowRegistryKey key) { string[] keys = key.GetSubKeyNames(); bool found = false; int i = 0; while ((i < keys.Length) && !found) { if (!(found = keys[i].Equals("ODP.NET"))) { if (!(found = HasOdpNetKey(key.OpenSubKey(keys[i])))) { i++; } } } return(found); }
private static string GetHomeKey(WowRegistryKey key) { string homeKey = (string)key.GetValue("ORACLE_HOME_KEY"); if ((homeKey == null) && (key != null)) { string[] keys = key.GetSubKeyNames(); int i = 0; while ((i < keys.Length) && (homeKey == null)) { var subkey = key.OpenSubKey(keys[i]); if ((homeKey = GetHomeKey(subkey)) == null) { i++; } } } return(homeKey); }