Skip to content

gutils.c: Improve g_get_os_info() for Windows 10/Server 2008 R2+

Chun-wei Fan requested to merge improve-win32-version into main


In issue #2443 (closed) it was pointed out that we aren't showing the right info for Windows 11 (and Windows 10/Server 2019 releases after 20H2, so this MR attempts to improve things by:

  • Reducing the calls to RtlGetVersion() to at most once whenever GLib is used in a program, since that should be all that is necessary (we won't get different results from it on the same running system). This will reduce the number of times that we need to go through LoadLibrary()/GetProcAddress() on non-UWP code as well.

  • Make the OSVERSIONINFOEXW that we get from RtlGetVersion() reusable, as we want to check for more fine-grained items like the build number, so that we can distinguish between Windows 10 or 11, and between Windows Server 2016 or 2019 or 2022. This means g_get_os_info() will tell us that we are on Windows 11 instead of Windows 10, and Windows Server 2016/2019/2022 instead of Windows 10 Server.

  • Look again in the registry to find the right Windows 10 update to display since ReleaseId was superseded by DisplayVersion since Windows 10/Server 2019 20H2 and later.

  • Also, improve the info shown when running on Windows Server 2008 R2 and later, so that instead of Windows 7/8/8.1 Server we now have Windows Server 2008 R2/2012/2012 R2 respectively.

This should fix issue #2443 (closed), and might fit into the glib-2-70 branch as well.

With blessings, thank you!

Edited by Chun-wei Fan

Merge request reports