Beispiel #1
0
            private unsafe windows_version(Interop.Kernel32.OSVERSIONINFOEX version)
                : this(version.dwMajorVersion, version.dwMinorVersion, version.dwBuildNumber, version.dwPlatformId, new string(version.szCSDVersion))
            {
                product_type       = version.wProductType;
                service_pack_major = version.wServicePackMajor;
                service_pack_minor = version.wServicePackMinor;
                suite_mask         = version.wSuiteMask;

                if (Interop.NtDll.RtlGetVersionEx(out var osVer) == 0)
                {
                    platform_version = PythonTuple.MakeTuple((int)osVer.dwMajorVersion, (int)osVer.dwMinorVersion, (int)osVer.dwBuildNumber);
                }
Beispiel #2
0
        private static unsafe OperatingSystem GetOSVersion()
        {
            var version = new Interop.Kernel32.OSVERSIONINFOEX {
                dwOSVersionInfoSize = sizeof(Interop.Kernel32.OSVERSIONINFOEX)
            };

            if (!Interop.Kernel32.GetVersionExW(ref version))
            {
                throw new InvalidOperationException(SR.InvalidOperation_GetVersion);
            }

            return(new OperatingSystem(
                       PlatformID.Win32NT,
                       new Version(version.dwMajorVersion, version.dwMinorVersion, version.dwBuildNumber, (version.wServicePackMajor << 16) | version.wServicePackMinor),
                       Marshal.PtrToStringUni((IntPtr)version.szCSDVersion)));
        }
Beispiel #3
0
            internal static windows_version GetWindowsVersion()
            {
                unsafe {
                    var version = new Interop.Kernel32.OSVERSIONINFOEX()
                    {
                        dwOSVersionInfoSize = sizeof(Interop.Kernel32.OSVERSIONINFOEX)
                    };

                    if (!Interop.Kernel32.GetVersionExW(ref version))
                    {
                        // TODO: can this fail? throw an OSError?
                        throw new InvalidOperationException();
                    }

                    return(new windows_version(version));
                }
            }
Beispiel #4
0
            private static bool GetIsWindows8OrAbove()
            {
                ulong conditionMask = Interop.Kernel32.VerSetConditionMask(0, Interop.Kernel32.VER_MAJORVERSION, Interop.Kernel32.VER_GREATER_EQUAL);

                conditionMask = Interop.Kernel32.VerSetConditionMask(conditionMask, Interop.Kernel32.VER_MINORVERSION, Interop.Kernel32.VER_GREATER_EQUAL);
                conditionMask = Interop.Kernel32.VerSetConditionMask(conditionMask, Interop.Kernel32.VER_SERVICEPACKMAJOR, Interop.Kernel32.VER_GREATER_EQUAL);
                conditionMask = Interop.Kernel32.VerSetConditionMask(conditionMask, Interop.Kernel32.VER_SERVICEPACKMINOR, Interop.Kernel32.VER_GREATER_EQUAL);

                // Windows 8 version is 6.2
                Interop.Kernel32.OSVERSIONINFOEX version = default;
                unsafe
                {
                    version.dwOSVersionInfoSize = sizeof(Interop.Kernel32.OSVERSIONINFOEX);
                }
                version.dwMajorVersion    = 6;
                version.dwMinorVersion    = 2;
                version.wServicePackMajor = 0;
                version.wServicePackMinor = 0;

                return(Interop.Kernel32.VerifyVersionInfoW(ref version,
                                                           Interop.Kernel32.VER_MAJORVERSION | Interop.Kernel32.VER_MINORVERSION | Interop.Kernel32.VER_SERVICEPACKMAJOR | Interop.Kernel32.VER_SERVICEPACKMINOR,
                                                           conditionMask));
            }