internal static NamedKey[] GetInstances(byte[] bytes, string path, string key) { NamedKey hiveroot = RegistryHelper.GetRootKey(bytes, path); NamedKey nk = hiveroot; if (key != null) { foreach (string k in key.Split('\\')) { NamedKey startingkey = nk; foreach (NamedKey n in nk.GetSubKeys(bytes)) { if (n.Name.ToUpper() == k.ToUpper()) { nk = n; } } if (nk == startingkey) { throw new Exception(string.Format("Cannot find key '{0}' in the '{1}' hive because it does not exist.", key, path)); } } if (nk == hiveroot) { throw new Exception(string.Format("Cannot find key '{0}' in the '{1}' hive because it does not exist.", key, path)); } } return(nk.GetSubKeys(bytes)); }
internal static NamedKey GetOfficeKey(byte[] bytes, string path) { string key = @"Software\Microsoft\Office"; NamedKey OfficeKey = null; try { OfficeKey = NamedKey.Get(bytes, path, key); } catch { throw new Exception(String.Format("Microsoft Office is not installed on this system")); } foreach (NamedKey nk in OfficeKey.GetSubKeys(bytes)) { if (nk.Name.Contains(@".0")) { if (nk.Name != "8.0") { return(nk); } } } throw new Exception("Could not locate the Microsoft Office registry key"); }
internal static string GetOfficeVersion(byte[] bytes, string hivePath) { NamedKey OfficeKey = null; try { OfficeKey = NamedKey.Get(bytes, hivePath, @"Software\Microsoft\Office"); } catch { throw new Exception(String.Format("Microsoft Office is not installed on this system")); } foreach (NamedKey nk in OfficeKey.GetSubKeys(bytes)) { if (nk.Name.Contains(@".0")) { if (nk.Name != "8.0") { return(nk.FullName.Split('\\')[4]); } } } throw new Exception("Could not locate the Microsoft Office registry key"); }
internal static ValueKey Get(byte[] bytes, string path, string key, string val) { NamedKey hiveroot = RegistryHelper.GetRootKey(bytes, path); NamedKey nk = hiveroot; if (key != null) { foreach (string k in key.Split('\\')) { foreach (NamedKey n in nk.GetSubKeys(bytes)) { if (n.Name.ToUpper() == k.ToUpper()) { nk = n; } } } } ValueKey[] values = nk.GetValues(bytes); foreach (ValueKey v in values) { if (v.Name.ToUpper() == val.ToUpper()) { return(v); } } return(null); }
private static NamedKey[] GetInstances(byte[] bytes, NamedKey nk, bool recurse) { List <NamedKey> keyList = new List <NamedKey>(); foreach (NamedKey subkey in nk.GetSubKeys(bytes)) { keyList.Add(subkey); if (subkey.NumberOfSubKeys > 0) { keyList.AddRange(GetInstances(bytes, subkey, true)); } } return(keyList.ToArray()); }
internal static ValueKey[] GetInstances(byte[] bytes, string path, string key) { NamedKey hiveroot = RegistryHelper.GetRootKey(bytes, path); NamedKey nk = hiveroot; if (key != null) { foreach (string k in key.Split('\\')) { foreach (NamedKey n in nk.GetSubKeys(bytes)) { if (n.Name.ToUpper() == k.ToUpper()) { nk = n; } } } } return(nk.GetValues(bytes)); }
/// <summary> /// /// </summary> /// <param name="path"></param> /// <param name="key"></param> /// <param name="val"></param> /// <returns></returns> public static ValueKey Get(string path, string key, string val) { byte[] bytes = RegistryHelper.GetHiveBytes(path); NamedKey hiveroot = RegistryHelper.GetRootKey(bytes, path); NamedKey nk = hiveroot; if (key != null) { foreach (string k in key.Split('\\')) { foreach (NamedKey n in nk.GetSubKeys(bytes)) { if (n.Name.ToUpper() == k.ToUpper()) { nk = n; } } } if (nk == hiveroot) { throw new Exception(string.Format("Cannot find key '{0}' in the '{1}' hive because it does not exist.", key, path)); } } ValueKey[] values = nk.GetValues(bytes); foreach (ValueKey v in values) { if (v.Name.ToUpper() == val.ToUpper()) { return(v); } } throw new Exception(string.Format("Cannot find value '{0}' as a value of '{1}' in the '{2}' hive because it does not exist.", val, key, path)); }
internal static NamedKey[] GetInstances(byte[] bytes, string path) { NamedKey hiveroot = RegistryHelper.GetRootKey(bytes, path); return(hiveroot.GetSubKeys()); }