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 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"); }
/// <summary> /// /// </summary> /// <param name="path"></param> /// <param name="key"></param> /// <returns></returns> public static NamedKey Get(string path, string key) { return(NamedKey.Get(RegistryHelper.GetHiveBytes(path), path, key.TrimEnd('\\'))); }