diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2021-08-21 14:08:22 +0200 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2021-08-21 14:08:22 +0200 |
| commit | bb86b0f526e0da2da4a75132dc47697d4cbe4552 (patch) | |
| tree | e4c29e41d6ae43183a2376187a992e4104bdae1e | |
| parent | 2f5edebefa75381283d75adcc4260277a3945524 (diff) | |
os: Add Windows 11 detection.
| -rw-r--r-- | core/os/os_windows.odin | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/core/os/os_windows.odin b/core/os/os_windows.odin index c8e4f8382..edba74504 100644 --- a/core/os/os_windows.odin +++ b/core/os/os_windows.odin @@ -160,6 +160,18 @@ _alloc_command_line_arguments :: proc() -> []string { return arg_list; } +/* + Windows 11 (preview) has the same major and minor version numbers + as Windows 10: 10 and 0 respectively. + + To determine if you're on Windows 10 or 11, we need to look at + the build number. As far as we can tell right now, the cutoff is build 22_000. + + TODO: Narrow down this range once Win 11 is published and the last Win 10 builds + become available. +*/ +WINDOWS_11_BUILD_CUTOFF :: 22_000; + get_windows_version_w :: proc() -> win32.OSVERSIONINFOEXW { osvi : win32.OSVERSIONINFOEXW; osvi.dwOSVersionInfoSize = size_of(win32.OSVERSIONINFOEXW); @@ -194,5 +206,10 @@ is_windows_8_1 :: proc() -> bool { is_windows_10 :: proc() -> bool { osvi := get_windows_version_w(); - return (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0); + return (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber < WINDOWS_11_BUILD_CUTOFF); } + +is_windows_11 :: proc() -> bool { + osvi := get_windows_version_w(); + return (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber >= WINDOWS_11_BUILD_CUTOFF); +}
\ No newline at end of file |