Skip to content

Commit

Permalink
ui: Get Windows product and build number
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabxx authored Jun 12, 2023
1 parent bb05a4f commit af3f832
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions ui/xemu-os-utils-windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,49 @@

#include "xemu-os-utils.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)
{
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)
{
ShellExecute(0, "open", url, 0, 0 , SW_SHOW);
ShellExecute(0, "open", url, 0, 0, SW_SHOW);
}

0 comments on commit af3f832

Please sign in to comment.