Beispiel #1
0
//-----------------------------------------------------------------------------
// overrides

        public override bool Equals(object o)
        {
            OSVersionInfo p = o as OSVersionInfo;

            if (p != null)
            {
                return(this == p);
            }

            return(base.Equals(o));
        }
Beispiel #2
0
        private void CopyThis(OSVersionInfo o)
        {
            // normal fields
            _OSPlatformId = o._OSPlatformId;

            _MajorVersion = o._MajorVersion;
            _MinorVersion = o._MinorVersion;
            _BuildNumber  = o._BuildNumber;
            _CSDVersion   = o._CSDVersion;

            // extended fields
            _OSSuiteFlags  = o._OSSuiteFlags;
            _OSProductType = o._OSProductType;

            _ServicePackMajor = o._ServicePackMajor;
            _ServicePackMinor = o._ServicePackMinor;
            _Reserved         = o._Reserved;

            // state fields
//			_Locked                   = o._Locked                   ;
            _Locked = false;
            _ExtendedPropertiesAreSet = o._ExtendedPropertiesAreSet;
        }
Beispiel #3
0
        public virtual int CompareTo(object o)
        {
            if (o == null)
            {
                throw new InvalidOperationException("CompareTo( object o ): 'o' is null");
            }

            OSVersionInfo p = o as OSVersionInfo;

            if (p == null)
            {
                throw new InvalidOperationException("CompareTo( object o ): 'o' is not an OSVersionInfo");
            }

            if (this == p)
            {
                return(0);
            }
            if (this > p)
            {
                return(1);
            }
            return(-1);
        }
Beispiel #4
0
        public static string GetSystemName()
        {
            OsVersionInfo osVersionInfo = default(OsVersionInfo);

            osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(typeof(OsVersionInfo));
            if (OSVersionInfo.GetVersionEx(ref osVersionInfo))
            {
                OperatingSystem osVersion = Environment.OSVersion;
                switch (osVersion.Platform)
                {
                case PlatformID.Win32S:
                    return("Windows 3.1");

                case PlatformID.Win32Windows:
                    if (osVersion.Version.Major == 4)
                    {
                        string csdVersion = osVersionInfo.szCSDVersion;
                        if (osVersion.Version.Minor != 0)
                        {
                            if (osVersion.Version.Minor != 10)
                            {
                                if (osVersion.Version.Minor == 90)
                                {
                                    return("Windows Me");
                                }
                            }
                            else
                            {
                                if (csdVersion == "A")
                                {
                                    return("Windows 98 Second Edition");
                                }
                                return("Windows 98");
                            }
                        }
                        else
                        {
                            if (csdVersion == "B" || csdVersion == "C")
                            {
                                return("Windows 95 OSR2");
                            }
                            return("Windows 95");
                        }
                    }
                    break;

                case PlatformID.Win32NT:
                {
                    byte productType = osVersionInfo.wProductType;
                    switch (osVersion.Version.Major)
                    {
                    case 3:
                        return("Windows NT 3.51");

                    case 4:
                        switch (productType)
                        {
                        case 1:
                            return("Windows NT 4.0");

                        case 3:
                            return("Windows NT 4.0 Server");
                        }
                        break;

                    case 5:
                        switch (osVersion.Version.Minor)
                        {
                        case 0:
                            return("Windows 2000");

                        case 1:
                            return("Windows XP");

                        case 2:
                            return("Windows Server 2003");
                        }
                        break;

                    case 6:
                        switch (osVersion.Version.Minor)
                        {
                        case 0:
                            switch (productType)
                            {
                            case 1:
                                return("Windows Vista");

                            case 3:
                                return("Windows Server 2008");
                            }
                            break;

                        case 1:
                            switch (productType)
                            {
                            case 1:
                                return("Windows 7");

                            case 3:
                                return("Windows Server 2008 R2");
                            }
                            break;

                        case 2:
                            switch (productType)
                            {
                            case 1:
                                return("Windows 8");

                            case 3:
                                return("Windows Server 2012");
                            }
                            break;
                        }
                        break;
                    }
                    break;
                }

                case PlatformID.WinCE:
                    return("Windows CE");
                }
            }
            return("Unknown");
        }
Beispiel #5
0
 public virtual void Copy(OSVersionInfo o)
 {
     CopyThis(o);
 }
Beispiel #6
0
//-----------------------------------------------------------------------------
// Copying

        public OSVersionInfo(OSVersionInfo o)
        {
            CopyThis(o);
        }
Beispiel #7
0
 //-----------------------------------------------------------------------------
 // Copying
 public OSVersionInfo( OSVersionInfo o )
 {
     CopyThis( o );
 }
Beispiel #8
0
        private void CopyThis( OSVersionInfo o )
        {
            // normal fields
            _OSPlatformId             = o._OSPlatformId             ;

            _MajorVersion             = o._MajorVersion             ;
            _MinorVersion             = o._MinorVersion             ;
            _BuildNumber              = o._BuildNumber              ;
            _CSDVersion               = o._CSDVersion               ;

            // extended fields
            _OSSuiteFlags             = o._OSSuiteFlags             ;
            _OSProductType            = o._OSProductType            ;

            _ServicePackMajor         = o._ServicePackMajor         ;
            _ServicePackMinor         = o._ServicePackMinor         ;
            _Reserved                 = o._Reserved;

            // state fields
            //			_Locked                   = o._Locked                   ;
            _Locked                   = false                       ;
            _ExtendedPropertiesAreSet = o._ExtendedPropertiesAreSet ;
        }
Beispiel #9
0
 public virtual void Copy( OSVersionInfo o )
 {
     CopyThis( o );
 }