internal static Version GetRealWindowsVersion() { var version = new RTL_OSVERSIONINFOEXW { dwOSVersionInfoSize = (uint)Marshal.SizeOf(typeof(RTL_OSVERSIONINFOEXW)) }; // RtlGetVersion does not require a manifest to detect Windows 10+. int st = RtlGetVersion(ref version); if (st != 0) { throw Marshal.GetExceptionForHR(st); } return(new Version( (int)version.dwMajorVersion, (int)version.dwMinorVersion, (int)version.dwBuildNumber, (version.wServicePackMajor << 16) | version.wServicePackMinor)); }
internal static extern bool RtlGetVersion([MarshalAs(UnmanagedType.Struct)] ref RTL_OSVERSIONINFOEXW lpVersionInformation);
private static extern int RtlGetVersion(ref RTL_OSVERSIONINFOEXW lpVersionInformation);