// Copyright (c) Dapplo and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; namespace GreenshotPlugin.Core { /// /// Extension methods to test the windows version /// public static class WindowsVersion { /// /// Get the current windows version /// public static Version WinVersion { get; } = Environment.OSVersion.Version; /// /// Test if the current OS is Windows 10 /// /// true if we are running on Windows 10 public static bool IsWindows10 { get; } = WinVersion.Major == 10; /// /// Test if the current OS is Windows 10 or later /// /// true if we are running on Windows 10 or later public static bool IsWindows10OrLater { get; } = WinVersion.Major >= 10; /// /// Test if the current OS is Windows 7 or later /// /// true if we are running on Windows 7 or later public static bool IsWindows7OrLater { get; } = WinVersion.Major == 6 && WinVersion.Minor >= 1 || WinVersion.Major > 6; /// /// Test if the current OS is Windows 8.0 /// /// true if we are running on Windows 8.0 public static bool IsWindows8 { get; } = WinVersion.Major == 6 && WinVersion.Minor == 2; /// /// Test if the current OS is Windows 8(.1) /// /// true if we are running on Windows 8(.1) public static bool IsWindows81 { get; } = WinVersion.Major == 6 && WinVersion.Minor == 3; /// /// Test if the current OS is Windows 8.0 or 8.1 /// /// true if we are running on Windows 8.1 or 8.0 public static bool IsWindows8X { get; } = IsWindows8 || IsWindows81; /// /// Test if the current OS is Windows 8.1 or later /// /// true if we are running on Windows 8.1 or later public static bool IsWindows81OrLater { get; } = WinVersion.Major == 6 && WinVersion.Minor >= 3 || WinVersion.Major > 6; /// /// Test if the current OS is Windows 8 or later /// /// true if we are running on Windows 8 or later public static bool IsWindows8OrLater { get; } = WinVersion.Major == 6 && WinVersion.Minor >= 2 || WinVersion.Major > 6; /// /// Test if the current OS is Windows Vista /// /// true if we are running on Windows Vista or later public static bool IsWindowsVista { get; } = WinVersion.Major >= 6 && WinVersion.Minor == 0; /// /// Test if the current OS is Windows Vista or later /// /// true if we are running on Windows Vista or later public static bool IsWindowsVistaOrLater { get; } = WinVersion.Major >= 6; /// /// Test if the current OS is from before Windows Vista (e.g. Windows XP) /// /// true if we are running on Windows from before Vista public static bool IsWindowsBeforeVista { get; } = WinVersion.Major < 6; /// /// Test if the current OS is Windows XP /// /// true if we are running on Windows XP or later public static bool IsWindowsXp { get; } = WinVersion.Major == 5 && WinVersion.Minor >= 1; /// /// Test if the current OS is Windows XP or later /// /// true if we are running on Windows XP or later public static bool IsWindowsXpOrLater { get; } = WinVersion.Major >= 5 || WinVersion.Major == 5 && WinVersion.Minor >= 1; /// /// Test if the current Windows version is 10 and the build number or later /// See the build numbers here /// /// int /// bool public static bool IsWindows10BuildOrLater(int minimalBuildNumber) { return IsWindows10 && WinVersion.Build >= minimalBuildNumber; } } }