ThePhD / infoware

C++ Library for pulling system and hardware information, without hitting the command line.
Creative Commons Zero v1.0 Universal
410 stars 84 forks source link

Get windows version from WinAPI/registry instead of kernel version #55

Closed demian51 closed 3 years ago

demian51 commented 3 years ago

Currently, infoware gets OS version from kernel version in Windows. But the OS version of Windows can be different from the kernel version. For example, I'm using Windows 10 21H1, and its version is 10.0.19043.1165. But its kernel version(and OS_info() of infoware) says 10.0.19041.1151.

This pull request fixes this issue by getting the OS version from RtlGetVersion and registry key UBR or BuildLabEx. Although GetVersionEx is deprecated, RtlGetVersion still works well in the latest Windows. And we can get the build number(in windows, it is called "UBR") from registry key UBR(later version of Windows 8.1 and above) or BuildLabEx(early version of Windows 8.1 and below).

Refers to: https://github.com/PSAppDeployToolkit/PSAppDeployToolkit/issues/251

nabijaczleweli commented 3 years ago

Squashed and applied with minor editorial changes in 19cf89c684f84a01033c3bcf4c9989e6dee824d2, thanks!