diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2023-11-16 04:07:19 +0100 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2024-03-18 02:22:28 +0000 |
commit | e8b085fbb5a880ae6a7b1ca35496f505cd99fcd3 (patch) | |
tree | c3242d93d23024895968ea7795b0f7bb61295206 | |
parent | ad093567e8ce8ace520412086907b9ea64299865 (diff) | |
download | mpv-e8b085fbb5a880ae6a7b1ca35496f505cd99fcd3.tar.bz2 mpv-e8b085fbb5a880ae6a7b1ca35496f505cd99fcd3.tar.xz |
win32: add helper function to check Windows 10 build number
-rw-r--r-- | video/out/w32_common.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/video/out/w32_common.c b/video/out/w32_common.c index a4e61a3db5..ea1f5588fd 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -217,6 +217,25 @@ static void adjust_window_rect(struct vo_w32_state *w32, HWND hwnd, RECT *rc) } } +static bool check_windows10_build(DWORD build) +{ + OSVERSIONINFOEXW osvi = { + .dwOSVersionInfoSize = sizeof(osvi), + .dwMajorVersion = HIBYTE(_WIN32_WINNT_WIN10), + .dwMinorVersion = LOBYTE(_WIN32_WINNT_WIN10), + .dwBuildNumber = build, + }; + + DWORD type = VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER; + + ULONGLONG mask = 0; + mask = VerSetConditionMask(mask, VER_MAJORVERSION, VER_GREATER_EQUAL); + mask = VerSetConditionMask(mask, VER_MINORVERSION, VER_GREATER_EQUAL); + mask = VerSetConditionMask(mask, VER_BUILDNUMBER, VER_GREATER_EQUAL); + + return VerifyVersionInfoW(&osvi, type, mask); +} + // Get adjusted title bar height, only relevant for --title-bar=no static int get_title_bar_height(struct vo_w32_state *w32) { @@ -1894,14 +1913,7 @@ static void w32_api_load(struct vo_w32_state *w32) // may point to unexpected code/data. Alternatively could check uxtheme.dll // version directly, but it is little bit more boilerplate code, and build // number is good enough check. - void (WINAPI *pRtlGetNtVersionNumbers)(LPDWORD, LPDWORD, LPDWORD) = - (void *)GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "RtlGetNtVersionNumbers"); - - DWORD major, build; - pRtlGetNtVersionNumbers(&major, NULL, &build); - build &= ~0xF0000000; - - HMODULE uxtheme_dll = (major < 10 || build < 17763) ? NULL : + HMODULE uxtheme_dll = !check_windows10_build(17763) ? NULL : GetModuleHandle(L"uxtheme.dll"); w32->api.pShouldAppsUseDarkMode = !uxtheme_dll ? NULL : (void *)GetProcAddress(uxtheme_dll, MAKEINTRESOURCEA(132)); |