ui: Get Windows product and build number

This commit is contained in:
Fabx 2023-06-12 20:04:02 +02:00 committed by GitHub
parent bb05a4f181
commit af3f832fd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 38 additions and 2 deletions

View File

@ -19,13 +19,49 @@
#include "xemu-os-utils.h" #include "xemu-os-utils.h"
#include <windows.h> #include <windows.h>
#include <glib.h>
#include <glib/gprintf.h>
#include <wchar.h>
static const char *get_windows_build_info(void)
{
WCHAR current_build[1024], product_name[1024];
WCHAR build_size = 1024, product_size = 1024;
if (RegGetValueW(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
L"ProductName", RRF_RT_REG_SZ, (LPVOID)NULL, &product_name,
(LPDWORD)&product_size) != ERROR_SUCCESS) {
return "Windows";
}
if ((RegGetValueW(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
L"DisplayVersion", RRF_RT_REG_SZ, (LPVOID)NULL,
&current_build, (LPDWORD)&build_size) == ERROR_SUCCESS) ||
(RegGetValueW(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
L"CSDVersion", RRF_RT_REG_SZ, (LPVOID)NULL,
&current_build, (LPDWORD)&build_size) == ERROR_SUCCESS)) {
return g_strdup_printf("%ls %ls", product_name, current_build);
}
return g_strdup_printf("%ls", product_name);
}
const char *xemu_get_os_info(void) const char *xemu_get_os_info(void)
{ {
return "Windows"; static const char *buffer = NULL;
if (buffer == NULL) {
buffer = get_windows_build_info();
}
return buffer;
} }
void xemu_open_web_browser(const char *url) void xemu_open_web_browser(const char *url)
{ {
ShellExecute(0, "open", url, 0, 0 , SW_SHOW); ShellExecute(0, "open", url, 0, 0, SW_SHOW);
} }