コード例 #1
0
        /// <summary>
        /// Retrieves the current Operating System information.
        /// </summary>
        /// <returns></returns>
        /// <remarks></remarks>
        internal static OSVERSIONINFOEX GetOSInfo()
        {
            var lpOS = new OSVERSIONINFOEX();

            lpOS.dwOSVersionInfoSize = Marshal.SizeOf(lpOS);
            GetVersionExW(ref lpOS);
            var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion");

            if (key is object)
            {
                int    maj   = Conversions.ToInteger(key.GetValue("CurrentMajorVersionNumber"));
                int    min   = Conversions.ToInteger(key.GetValue("CurrentMinorVersionNumber"));
                int    build = Conversions.ToInteger(key.GetValue("CurrentBuildNumber"));
                string name  = Conversions.ToString(key.GetValue("ProductName"));
                lpOS.dwMajorVersion = maj;
                lpOS.dwMinorVersion = min;
                lpOS.dwBuildNumber  = build;
                key.Close();
            }

            // Try
            // If IsWindowsVersionOrGreater(6, 4, 0) Then
            // lpOS.dwMinorVersion = 4
            // End If
            // Catch ex As Exception
            // lpOS.dwMinorVersion = 4

            // End Try

            return(lpOS);
        }
コード例 #2
0
        /// <summary>
        /// Retrieves the current Operating System information.
        /// </summary>
        /// <returns></returns>
        /// <remarks></remarks>
        internal static OSVersionInfo GetOSInfo()
        {
            var lpOS = new OSVERSIONINFOEX();

            lpOS.dwOSVersionInfoSize = Marshal.SizeOf(lpOS);
            string dispVer = null;

            GetVersionExW(ref lpOS);

            var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion");

            if (key is object)
            {
                int maj = (int)(key.GetValue("CurrentMajorVersionNumber"));
                int min = (int)(key.GetValue("CurrentMinorVersionNumber"));

                int cb    = int.Parse((string)key.GetValue("CurrentBuildNumber"));
                int build = cb;

                dispVer = (string)key.GetValue("DisplayVersion");

                //string name = (string)(key.GetValue("ProductName"));

                lpOS.dwMajorVersion = maj;
                lpOS.dwMinorVersion = min;
                lpOS.dwBuildNumber  = build;

                key.Close();
            }

            return(new OSVersionInfo(lpOS, dispVer));
        }
コード例 #3
0
        internal OSVersionInfo(OSVERSIONINFOEX source, string displayVersion)
        {
            if (source.dwBuildNumber >= 22000 && source.dwMajorVersion == 10)
            {
                source.dwMajorVersion = 11;
            }

            Source = source;
            this.displayVersion = displayVersion;
        }
コード例 #4
0
 /// <summary>
 /// Finds the OSVersionNames object for the operating system data specified in the osx parameter.
 /// </summary>
 /// <param name="osx">Version information of the operating system for which to retrieve the object.</param>
 /// <returns>An OSVersionNames object.</returns>
 /// <remarks></remarks>
 internal static OSVersionNames FindVersion(OSVERSIONINFOEX osx)
 {
     return(FindVersion(osx.dwMajorVersion, osx.dwMinorVersion, osx.wProductType != OSProductType.NTWorkstation));
 }
コード例 #5
0
 internal static extern int GetVersionExW([MarshalAs(UnmanagedType.Struct)] ref OSVERSIONINFOEX pData);