Example #1
0
        internal unsafe static int RtlGetVersionEx(out RTL_OSVERSIONINFOEX osvi)
        {
            osvi = new RTL_OSVERSIONINFOEX();

            osvi.dwOSVersionInfoSize = (uint)sizeof(RTL_OSVERSIONINFOEX);
            return(RtlGetVersion(ref osvi));
        }
        private static unsafe int GetWindowsVersion()
        {
            var osvi = new RTL_OSVERSIONINFOEX();

            osvi.dwOSVersionInfoSize = (uint)sizeof(RTL_OSVERSIONINFOEX);
            Assert.Equal(0, RtlGetVersion(ref osvi));
            return((int)osvi.dwMajorVersion);
        }
        private static int GetWindowsVersion()
        {
            RTL_OSVERSIONINFOEX osvi = new RTL_OSVERSIONINFOEX();

            osvi.dwOSVersionInfoSize = (uint)Marshal.SizeOf(osvi);
            Assert.Equal(0, RtlGetVersion(out osvi));
            return((int)osvi.dwMajorVersion);
        }
 internal static unsafe int RtlGetVersion(out RTL_OSVERSIONINFOEX versionInfo)
 {
     versionInfo = new RTL_OSVERSIONINFOEX
     {
         dwOSVersionInfoSize = (uint)sizeof(RTL_OSVERSIONINFOEX)
     };
     return(RtlGetVersionInternal(ref versionInfo));
 }
Example #5
0
        private static bool IsWindows10Impl()
        {
            var osv = new RTL_OSVERSIONINFOEX();

            osv.dwOSVersionInfoSize = (uint)Marshal.SizeOf(osv);
            int ret = RtlGetVersion(out osv);

            return(ret == 0 && osv.dwMajorVersion >= 10);
        }
Example #6
0
            internal static string RtlGetVersion()
            {
                var osvi = new RTL_OSVERSIONINFOEX();

                osvi.dwOSVersionInfoSize = (uint)Marshal.SizeOf(osvi);
                return(RtlGetVersion(out osvi) == 0
                                        ? $"Microsoft Windows {osvi.dwMajorVersion}.{osvi.dwMinorVersion}.{osvi.dwBuildNumber}"
                                        : null);
            }
Example #7
0
        private static Version GetOSVersion()
        {
            var osv = new RTL_OSVERSIONINFOEX();

            osv.dwOSVersionInfoSize = (uint)Marshal.SizeOf(osv);
            int ret = RtlGetVersion(out osv);

            Debug.Assert(ret == 0);
            return(new Version((int)osv.dwMajorVersion, (int)osv.dwMinorVersion, (int)osv.dwBuildNumber));
        }
Example #8
0
        // Code borrowed from CoreFX System.PlatformDetection.Windows to allow targeting nestandard1.6
        public static bool AtLeast(int requiredOSVersion)
        {
            RTL_OSVERSIONINFOEX osvi = new RTL_OSVERSIONINFOEX();

            osvi.dwOSVersionInfoSize = (uint)Marshal.SizeOf(osvi);
            RtlGetVersion(out osvi);
            uint osVersion = osvi.dwMajorVersion * 10 + osvi.dwMinorVersion;

            return(osVersion >= requiredOSVersion);
        }
Example #9
0
        private static unsafe int GetWindowsBuildNumber()
        {
            var osvi = new RTL_OSVERSIONINFOEX
            {
                dwOSVersionInfoSize = (uint)sizeof(RTL_OSVERSIONINFOEX)
            };

            Assert.Equal(0, RtlGetVersion(ref osvi));
            return((int)osvi.dwBuildNumber);
        }
Example #10
0
        private static unsafe int GetWindowsBuildNumber()
        {
            var osvi = new RTL_OSVERSIONINFOEX
            {
                dwOSVersionInfoSize = (uint)Unsafe.SizeOf <RTL_OSVERSIONINFOEX>()
            };

            Debug.Assert(RtlGetVersion(ref osvi) == 0);
            return((int)osvi.dwBuildNumber);
        }
Example #11
0
        private static unsafe int GetWindowsMinorVersion()
        {
            var osvi = new RTL_OSVERSIONINFOEX
            {
                dwOSVersionInfoSize = (uint)Unsafe.SizeOf <RTL_OSVERSIONINFOEX>()
            };
            var result = RtlGetVersion(ref osvi);

            Debug.Assert(result == 0);
            return((int)osvi.dwMinorVersion);
        }
            private static RTL_OSVERSIONINFOEX InitVersion()
            {
                // We use RtlGetVersion as it isn't subject to version lie. GetVersion
                // won't tell you the real version unless the launching exe is manifested
                // with the latest OS version.

                RTL_OSVERSIONINFOEX info = new RTL_OSVERSIONINFOEX();

                RtlGetVersion(ref info);
                return(info);
            }
Example #13
0
        private static int GetWindowsVersion()
        {
            if (IsWindows)
            {
                RTL_OSVERSIONINFOEX osvi = new RTL_OSVERSIONINFOEX();
                osvi.dwOSVersionInfoSize = (uint)Marshal.SizeOf(osvi);
                Assert.Equal(0, RtlGetVersion(out osvi));
                return (int)osvi.dwMajorVersion;
            }

            return -1;
        }
Example #14
0
        internal static string RtlGetVersion()
        {
            var osvi = new RTL_OSVERSIONINFOEX();

            osvi.dwOSVersionInfoSize = (uint)Marshal.SizeOf(osvi);
            if (RtlGetVersion(out osvi) == 0)
            {
                return($"{osvi.dwMajorVersion}.{osvi.dwMinorVersion}.{osvi.dwBuildNumber}");
            }

            return(null);
        }
Example #15
0
        private static int GetWindowsBuildNumber()
        {
            if (IsWindows)
            {
                RTL_OSVERSIONINFOEX osvi = new RTL_OSVERSIONINFOEX();
                osvi.dwOSVersionInfoSize = (uint)Marshal.SizeOf(osvi);
                Assert.Equal(0, RtlGetVersion(out osvi));
                return((int)osvi.dwBuildNumber);
            }

            return(-1);
        }
 internal static string RtlGetVersion()
 {
     RTL_OSVERSIONINFOEX osvi = new RTL_OSVERSIONINFOEX();
     osvi.dwOSVersionInfoSize = (uint)Marshal.SizeOf(osvi);
     if (RtlGetVersion(out osvi) == 0)
     {
         return $"{osvi.dwMajorVersion}.{osvi.dwMinorVersion}.{osvi.dwBuildNumber}";
     }
     else
     {
         return null;
     }
 }
Example #17
0
            internal static Version RtlGetVersion()
            {
                RTL_OSVERSIONINFOEX v = new RTL_OSVERSIONINFOEX();

                v.dwOSVersionInfoSize = (uint)Marshal.SizeOf(v);
                if (RtlGetVersion(out v) == 0)
                {
                    return(new Version((int)v.dwMajorVersion, (int)v.dwMinorVersion, (int)v.dwBuildNumber, (int)v.dwPlatformId));
                }
                else
                {
                    throw new Exception("RtlGetVersion failed!");
                }
            }
Example #18
0
 internal static string RtlGetVersion()
 {
     RTL_OSVERSIONINFOEX osvi = new RTL_OSVERSIONINFOEX();
     osvi.dwOSVersionInfoSize = (uint)Marshal.SizeOf(osvi);
     const string version = "Microsoft Windows";
     if (RtlGetVersion(out osvi) == 0)
     {
         return string.Format("{0} {1}.{2}.{3} {4}",
             version, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber, osvi.szCSDVersion);
     }
     else
     {
         return version;
     }
 }
Example #19
0
            public static decimal RtlGetVersion()
            {
                RTL_OSVERSIONINFOEX osvi = new RTL_OSVERSIONINFOEX();

                osvi.dwOSVersionInfoSize = (uint)Marshal.SizeOf(osvi);
                //const string version = "Microsoft Windows";
                if (RtlGetVersion(out osvi) == 0)
                {
                    string Version = osvi.dwMajorVersion + "." + osvi.dwMinorVersion;
                    return(decimal.Parse(Version, CultureInfo.InvariantCulture));
                }
                else
                {
                    return(-1);
                }
            }
Example #20
0
        internal static string RtlGetVersion()
        {
            RTL_OSVERSIONINFOEX osvi = new RTL_OSVERSIONINFOEX();

            osvi.dwOSVersionInfoSize = (uint)Marshal.SizeOf(osvi);
            const string version = "Microsoft Windows";

            if (RtlGetVersion(out osvi) == 0)
            {
                return(string.Format("{0} {1}.{2}.{3} {4}",
                                     version, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber, osvi.szCSDVersion));
            }
            else
            {
                return(version);
            }
        }
Example #21
0
        internal static unsafe string RtlGetVersion()
        {
            var osvi = new RTL_OSVERSIONINFOEX();

            osvi.dwOSVersionInfoSize = (uint)sizeof(RTL_OSVERSIONINFOEX);
            const string version = "Microsoft Windows";

            if (RtlGetVersion(ref osvi) == 0)
            {
                return(string.Format("{0} {1}.{2}.{3} {4}",
                                     version, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber, new string(&(osvi.szCSDVersion[0]))));
            }
            else
            {
                return(version);
            }
        }
Example #22
0
 private static unsafe int RtlGetVersionEx(out RTL_OSVERSIONINFOEX osvi)
 {
     osvi = default;
     osvi.dwOSVersionInfoSize = (uint)sizeof(RTL_OSVERSIONINFOEX);
     return(RtlGetVersion(ref osvi));
 }
Example #23
0
 public static decimal RtlGetVersion()
 {
     RTL_OSVERSIONINFOEX osvi = new RTL_OSVERSIONINFOEX();
     osvi.dwOSVersionInfoSize = (uint)Marshal.SizeOf(osvi);
     //const string version = "Microsoft Windows";
     if (RtlGetVersion(out osvi) == 0)
     {
         string Version = osvi.dwMajorVersion + "." + osvi.dwMinorVersion;
         return decimal.Parse(Version, CultureInfo.InvariantCulture);
     }
     else
     {
         return -1;
     }
 }
Example #24
0
 private static extern int RtlGetVersion(out RTL_OSVERSIONINFOEX lpVersionInformation);
 private static partial int RtlGetVersion(ref RTL_OSVERSIONINFOEX lpVersionInformation);
Example #26
0
 private static extern int RtlGetVersion(out RTL_OSVERSIONINFOEX lpVersionInformation);
 public static extern int RtlGetVersion(ref RTL_OSVERSIONINFOEX lpVersionInformation);