Ejemplo n.º 1
0
        /// <summary>
        /// Indicates if the current OS is a Windows Server release. Applications that need to distinguish between server and client versions of Windows should call this function.
        /// </summary>
        /// <returns>True if the current OS is a Windows Server version; otherwise, false.</returns>
        public static bool IsWindowsServer()
        {
            var osvi = new OsVersionInfo {
                ProductType = OsProductTypes.Server
            }.AddCondition(VersionInfoParts.ProductType, Conditions.EqualTo);

            return(VerifyVersionInfo(osvi));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Indicates if the current OS version matches, or is greater than, the Windows XP version.
        /// </summary>
        /// <returns>True if the current OS version matches, or is greater than, the Windows XP version; otherwise, false.</returns>
        public static bool IsWindowsXPOrGreater()
        {
            var osvi = new OsVersionInfo
            {
                MajorVersion = 5,
                MinorVersion = 1
            }
            .AddCondition(VersionInfoParts.MajorVersion, Conditions.GreaterThanEqualTo)
            .AddCondition(VersionInfoParts.MinorVersion, Conditions.GreaterThanEqualTo);

            return(VerifyVersionInfo(osvi));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Indicates if the current OS version matches, or is greater than, the provided version information. This function is useful in confirming a version of Windows Server that doesn't share a version number with a client release.
        /// <para>
        /// Note: You should only use this function if the other provided version helper functions do not fit your scenario.
        /// </para>
        /// </summary>
        /// <param name="major">The major OS version number.</param>
        /// <param name="minor">The minor OS version number.</param>
        /// <param name="spMajor">The major Service Pack version number.</param>
        /// <returns>TRUE if the specified version matches, or is greater than, the version of the current Windows OS; otherwise, FALSE.</returns>
        public static bool IsWindowsVersionOrGreater(int major, int minor, int spMajor)
        {
            var osvi = new OsVersionInfo
            {
                MajorVersion     = major,
                MinorVersion     = minor,
                ServicePackMajor = spMajor
            }
            .AddCondition(VersionInfoParts.MajorVersion, Conditions.GreaterThanEqualTo)
            .AddCondition(VersionInfoParts.MinorVersion, Conditions.GreaterThanEqualTo)
            .AddCondition(VersionInfoParts.ServicePackMajor, Conditions.GreaterThanEqualTo);

            return(VerifyVersionInfo(osvi));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Indicates if the current OS version matches, or is greater than, the Windows 7 with Service Pack 1 (SP1) version.
        /// </summary>
        /// <returns>True if the current OS version matches, or is greater than, the Windows 7 with SP1 version; otherwise, false.</returns>
        public static bool IsWindows7SP1OrGreater()
        {
            var osvi = new OsVersionInfo
            {
                MajorVersion     = 6,
                MinorVersion     = 1,
                ServicePackMajor = 1
            }
            .AddCondition(VersionInfoParts.MajorVersion, Conditions.GreaterThanEqualTo)
            .AddCondition(VersionInfoParts.MinorVersion, Conditions.GreaterThanEqualTo)
            .AddCondition(VersionInfoParts.ServicePackMajor, Conditions.GreaterThanEqualTo);

            return(VerifyVersionInfo(osvi));;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Compares a set of operating system version requirements to the corresponding values for the currently running version of the system. This function is subject to manifest-based behavior.
 /// </summary>
 /// <param name="osvi">An <see cref="OsVersionInfo"/> object containing the operating system version requirements to compare.</param>
 /// <returns></returns>
 public static bool VerifyVersionInfo(OsVersionInfo osvi)
 {
     return(NativeMethods.VerifyVersionInfo(osvi.ToNativeType(), osvi.GetTypeMask(), osvi.GetConditionsMask()));
 }