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
217 }217 }
218}218}
219 219
220static 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
220// Get adjusted title bar height, only relevant for --title-bar=no239// Get adjusted title bar height, only relevant for --title-bar=no
221static int get_title_bar_height(struct vo_w32_state *w32)240static int get_title_bar_height(struct vo_w32_state *w32)
222{241{
@@ -1894,14 +1913,7 @@ static void w32_api_load(struct vo_w32_state *w32) · 1671 unmodified lines
1894 // may point to unexpected code/data. Alternatively could check uxtheme.dll1913 // may point to unexpected code/data. Alternatively could check uxtheme.dll
1895 // version directly, but it is little bit more boilerplate code, and build1914 // version directly, but it is little bit more boilerplate code, and build
1896 // number is good enough check.1915 // number is good enough check.
1897 void (WINAPI *pRtlGetNtVersionNumbers)(LPDWORD, LPDWORD, LPDWORD) =1916 HMODULE uxtheme_dll = !check_windows10_build(17763) ? NULL :
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 :
1905 GetModuleHandle(L"uxtheme.dll");1917 GetModuleHandle(L"uxtheme.dll");
1906 w32->api.pShouldAppsUseDarkMode = !uxtheme_dll ? NULL :1918 w32->api.pShouldAppsUseDarkMode = !uxtheme_dll ? NULL :
1907 (void *)GetProcAddress(uxtheme_dll, MAKEINTRESOURCEA(132));1919 (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