From 47aa56b3e9362c6867bd8e988b9dd752f9a7166f Mon Sep 17 00:00:00 2001 From: Ryan Foster Date: Mon, 19 Sep 2016 20:35:59 -0400 Subject: [PATCH] libobs/util: Fix Windows 10 revision detection Sometimes the revision number isn't put in to the kernel32.dll version information. It's best to use the registry in this case. --- libobs/util/platform-windows.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libobs/util/platform-windows.c b/libobs/util/platform-windows.c index b4201b903..4f3cb543f 100644 --- a/libobs/util/platform-windows.c +++ b/libobs/util/platform-windows.c @@ -754,6 +754,8 @@ bool get_dll_ver(const wchar_t *lib, struct win_version_info *ver_info) return true; } +#define WINVER_REG_KEY L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion" + void get_win_ver(struct win_version_info *info) { static struct win_version_info ver = {0}; @@ -765,6 +767,26 @@ void get_win_ver(struct win_version_info *info) if (!got_version) { get_dll_ver(L"kernel32", &ver); got_version = true; + + if (ver.major == 10 && ver.revis == 0) { + HKEY key; + DWORD size, win10_revision; + LSTATUS status; + + status = RegOpenKeyW(HKEY_LOCAL_MACHINE, + WINVER_REG_KEY, &key); + if (status != ERROR_SUCCESS) + return; + + size = sizeof(win10_revision); + + status = RegQueryValueExW(key, L"UBR", NULL, NULL, + (LPBYTE)&win10_revision, &size); + if (status == ERROR_SUCCESS) + ver.revis = (int)win10_revision; + + RegCloseKey(key); + } } *info = ver; -- GitLab