public KeyValuePair <string, string> FindFirstValue(params string[] keysToCheck) { foreach (string keyToCheck in keysToCheck) { string[] parts = keyToCheck.Split(@"\".ToCharArray()); IRegistryKeyWrapper key = _registryWrapper.OpenLocalMachineKey(parts[0]); for (int i = 1; i < parts.Length - 1; i++) { key = key.OpenSubKey(parts[i]); if (key == null) //key is null if it does not exist { break; } } if (key != null) //could open all keys now try to get the value { return(new KeyValuePair <string, string>(key.Name, key.GetValue(parts[parts.Length - 1]).ToString())); } } return(new KeyValuePair <string, string>()); //can't find anything so return an emtpy string }