History

win32: add helper function to check Windows 10 build number

Kacper Michajłow committed 3 years ago

Commit e8b085f1 parent ad093561 file · +20 −8Browse files

Unified · Split

video/out/w32_common.c+20−8
@@ -217,6 +217,25 @@ static void adjust_window_rect(struct vo_w32_state *w32, HWND hwnd, RECT *rc) · 216 unmodified lines
217217 }
218218 }
219219
220+static bool check_windows10_build(DWORD build)
221+{
222+ OSVERSIONINFOEXW osvi = {
223+ .dwOSVersionInfoSize = sizeof(osvi),
224+ .dwMajorVersion = HIBYTE(_WIN32_WINNT_WIN10),
225+ .dwMinorVersion = LOBYTE(_WIN32_WINNT_WIN10),
226+ .dwBuildNumber = build,
227+ };
228+
229+ DWORD type = VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER;
230+
231+ ULONGLONG mask = 0;
232+ mask = VerSetConditionMask(mask, VER_MAJORVERSION, VER_GREATER_EQUAL);
233+ mask = VerSetConditionMask(mask, VER_MINORVERSION, VER_GREATER_EQUAL);
234+ mask = VerSetConditionMask(mask, VER_BUILDNUMBER, VER_GREATER_EQUAL);
235+
236+ return VerifyVersionInfoW(&osvi, type, mask);
237+}
238+
220239 // Get adjusted title bar height, only relevant for --title-bar=no
221240 static int get_title_bar_height(struct vo_w32_state *w32)
222241 {
@@ -1894,14 +1913,7 @@ static void w32_api_load(struct vo_w32_state *w32) · 1671 unmodified lines
18941913 // may point to unexpected code/data. Alternatively could check uxtheme.dll
18951914 // version directly, but it is little bit more boilerplate code, and build
18961915 // number is good enough check.
1897− void (WINAPI *pRtlGetNtVersionNumbers)(LPDWORD, LPDWORD, LPDWORD) =
1898− (void *)GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "RtlGetNtVersionNumbers");
1899−
1900− DWORD major, build;
1901− pRtlGetNtVersionNumbers(&major, NULL, &build);
1902− build &= ~0xF0000000;
1903−
1904− HMODULE uxtheme_dll = (major < 10 || build < 17763) ? NULL :
1916+ HMODULE uxtheme_dll = !check_windows10_build(17763) ? NULL :
19051917 GetModuleHandle(L"uxtheme.dll");
19061918 w32->api.pShouldAppsUseDarkMode = !uxtheme_dll ? NULL :
19071919 (void *)GetProcAddress(uxtheme_dll, MAKEINTRESOURCEA(132));

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t