Browse Source

libobs: Log windows release version

This logs the Windows release version (e.g. 1809, 1903, etc)
jp9000 5 years ago
parent
commit
eadb96fbca
2 changed files with 18 additions and 2 deletions
  1. 8 2
      libobs/obs-windows.c
  2. 10 0
      libobs/util/platform-windows.c

+ 8 - 2
libobs/obs-windows.c

@@ -130,16 +130,22 @@ static void log_available_memory(void)
 	     (DWORD)(ms.ullAvailPhys / 1048576), note);
 }
 
+extern const char *get_win_release_id();
+
 static void log_windows_version(void)
 {
 	struct win_version_info ver;
 	get_win_ver(&ver);
 
+	const char *release_id = get_win_release_id();
+
 	bool b64 = is_64_bit_windows();
 	const char *windows_bitness = b64 ? "64" : "32";
 
-	blog(LOG_INFO, "Windows Version: %d.%d Build %d (revision: %d; %s-bit)",
-	     ver.major, ver.minor, ver.build, ver.revis, windows_bitness);
+	blog(LOG_INFO,
+	     "Windows Version: %d.%d Build %d (release: %s; revision: %d; %s-bit)",
+	     ver.major, ver.minor, ver.build, release_id, ver.revis,
+	     windows_bitness);
 }
 
 static void log_admin_status(void)

+ 10 - 0
libobs/util/platform-windows.c

@@ -36,6 +36,7 @@
 static bool have_clockfreq = false;
 static LARGE_INTEGER clock_freq;
 static uint32_t winver = 0;
+static char win_release_id[MAX_SZ_LEN] = "unavailable";
 
 static inline uint64_t get_clockfreq(void)
 {
@@ -927,6 +928,10 @@ static inline void get_reg_ver(struct win_version_info *ver)
 		ver->build = wcstol(str, NULL, 10);
 	}
 
+	if (get_reg_sz(key, L"ReleaseId", str, sizeof(str))) {
+		os_wcs_to_utf8(str, 0, win_release_id, MAX_SZ_LEN);
+	}
+
 	RegCloseKey(key);
 }
 
@@ -988,6 +993,11 @@ void get_win_ver(struct win_version_info *info)
 	*info = ver;
 }
 
+const char *get_win_release_id(void)
+{
+	return win_release_id;
+}
+
 uint32_t get_win_ver_int(void)
 {
 	return get_winver();