OperatingSystemVersionCheck.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / InterOp / OperatingSystemVersionCheck.cs / 1305600 / OperatingSystemVersionCheck.cs

                            //---------------------------------------------------------------------------- 
//
// Copyright (C) Microsoft Corporation.  All rights reserved.
//
//--------------------------------------------------------------------------- 

using System; 
 
namespace System.Windows.Interop
{ 
    /// 
    ///     Performs a simple check of the current operating system version.
    ///     Use this class to determine whether version specific features should
    ///     be enabled. 
    /// 
    internal static class OperatingSystemVersionCheck 
    { 
        internal static bool IsVersionOrLater(OperatingSystemVersion version)
        { 
            //
            int major;
            int minor;
            PlatformID platform = PlatformID.Win32NT; 
            switch (version)
            { 
                case OperatingSystemVersion.Windows7: 
                    major = 6;
                    minor = 1; 
                    break;

                case OperatingSystemVersion.WindowsVista:
                    major = 6; 
                    minor = 0;
                    break; 
 
                case OperatingSystemVersion.WindowsXPSP2:
                default: 
                    major = 5;
                    minor = 1;
                    break;
            } 

            OperatingSystem os = Environment.OSVersion; 
            return (os.Platform == platform) && 
                (((os.Version.Major == major) && (os.Version.Minor >= minor)) || (os.Version.Major > major));
        } 
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//---------------------------------------------------------------------------- 
//
// Copyright (C) Microsoft Corporation.  All rights reserved.
//
//--------------------------------------------------------------------------- 

using System; 
 
namespace System.Windows.Interop
{ 
    /// 
    ///     Performs a simple check of the current operating system version.
    ///     Use this class to determine whether version specific features should
    ///     be enabled. 
    /// 
    internal static class OperatingSystemVersionCheck 
    { 
        internal static bool IsVersionOrLater(OperatingSystemVersion version)
        { 
            //
            int major;
            int minor;
            PlatformID platform = PlatformID.Win32NT; 
            switch (version)
            { 
                case OperatingSystemVersion.Windows7: 
                    major = 6;
                    minor = 1; 
                    break;

                case OperatingSystemVersion.WindowsVista:
                    major = 6; 
                    minor = 0;
                    break; 
 
                case OperatingSystemVersion.WindowsXPSP2:
                default: 
                    major = 5;
                    minor = 1;
                    break;
            } 

            OperatingSystem os = Environment.OSVersion; 
            return (os.Platform == platform) && 
                (((os.Version.Major == major) && (os.Version.Minor >= minor)) || (os.Version.Major > major));
        } 
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK