/// <summary> /// 获得操作系统名称 /// </summary> /// <returns></returns> public static string GetOSVersionName() { OsEntry curEntry = OsEntry.CurrentOsEntry(); var kvs = osEntries.Where(x => x.Value.Equals(curEntry)); if (kvs.Any()) { string osName = null; var das = kvs.Select(kv => DescriptionAttribute.GetDescription(kv.Key)); if (das.Count() == 2) { if (IsWindowsServer) { osName = das.First(da => da.Tag == 1).Text; } else { osName = das.First(da => da.Tag == 0).Text; } } else { osName = das.First().Text; } return($"{osName} ({(Environment.Is64BitOperatingSystem ? "64" : "32")}位)"); } else { return("UnKnow"); } }
/// <summary> /// Indicates if the running OS version matches, or is greater than, /// the provided OS. /// </summary> /// <param name="os">OS to compare running OS to.</param> /// <returns>True if the the running OS matches, or is greater /// than, the specified OS; otherwise, false.</returns> public static bool IsWindowsVersionOrGreater(KnownOS os) { try { OsEntry osEntry = osEntries[os]; if (!osEntry.MatchesOrGreater.HasValue) { osEntry.MatchesOrGreater = IsWindowsVersionOrGreater( osEntry.MajorVersion, osEntry.MinorVersion, osEntry.ServicePackMajor); } return osEntry.MatchesOrGreater.Value; } catch (KeyNotFoundException e) { throw new ArgumentException(Resources.UnknownOS, e); } }
/// <summary> /// Indicates if the running OS version matches, or is greater than, /// the provided OS. /// </summary> /// <param name="os">OS to compare running OS to.</param> /// <returns>True if the the running OS matches, or is greater /// than, the specified OS; otherwise, false.</returns> public static bool IsWindowsVersionOrGreater(KnownOS os) { try { OsEntry osEntry = osEntries[os]; if (!osEntry.MatchesOrGreater.HasValue) { osEntry.MatchesOrGreater = IsWindowsVersionOrGreater( osEntry.MajorVersion, osEntry.MinorVersion, osEntry.ServicePackMajor); } return(osEntry.MatchesOrGreater.Value); } catch (KeyNotFoundException e) { throw new ArgumentException("Unknown operating system. " + "Use overloaded version of IsWindowsVersionOrGreater " + "with version parameters.", e); } }