using System; using System.Collections.Generic; using System.Linq; using System.Text; using Yaulw.Win32; namespace Yaulw.Other { #region OSInfo Enums /// /// Windows OS Types /// public enum OStype { WIN_2000 = 4, WIN_2003 = 5, WIN_VISTA = 6, WIN_7 = 7, WIN_8 = 8, WIN_UNKNOWN = -1, } #endregion /// /// This class provides OS Specific and Version information to the caller /// public static class OSInfo { #region Public Properties /// /// Get OSType and Version Information /// public static int Major { get; private set; } public static int Minor { get; private set; } public static OStype OS { get; private set; } /// /// Set Supported Version for an Application /// public static OStype MinVersionSupported { get; set; } public static OStype MaxVersionSupported { get; set; } /// /// Is this OS Version Supported * Min/Max Should be set by Application * /// public static bool IsSupportedOS { get { if (MinVersionSupported != OStype.WIN_UNKNOWN && MaxVersionSupported != OStype.WIN_UNKNOWN) return ((int) OS >= (int)MinVersionSupported) && ((int) OS <= (int)MaxVersionSupported); else return true; } } /// /// Is Vista/Win7's Aero Enabled /// public static bool IsAero { get { if (((int)OS >= (int)OStype.WIN_VISTA) || ((int)OS <= (int)OStype.WIN_7)) { bool IsAero = false; if (uxDwm.DwmIsCompositionEnabled(ref IsAero) < 0) return false; else return IsAero; } return false; } } /// /// Is WindowsXP/2003 Composition Enabled /// public static bool IsXPComposition { get { if ((int)OS == (int)OStype.WIN_2003) return uxDwm.IsAppThemed(); return false; } } #endregion #region Construction /// /// Constructor /// static OSInfo() { // Get the OS Version Major = System.Environment.OSVersion.Version.Major; Minor = System.Environment.OSVersion.Version.Minor; // Parse the OS Version try { OSInfo.OS = (OStype)Enum.Parse(typeof(OStype), Major.ToString()); } catch (Exception) { OSInfo.OS = OStype.WIN_UNKNOWN; } // Set Min/Max to Unknown MinVersionSupported = OStype.WIN_UNKNOWN; MaxVersionSupported = OStype.WIN_UNKNOWN; } #endregion } }