version: report correct friendly-name for windows 10/11 versions after 2004

Until Windows 10 version 2004 (May 2020) this can be found from registry entry
ReleaseID, after that we must use entry DisplayVersion (ReleaseId is stuck at 2009).
Source: https://ss64.com/nt/ver.html
This commit is contained in:
albertony 2022-01-21 15:30:06 +01:00
parent c504d97017
commit 2523dd6220

View File

@ -39,10 +39,19 @@ func GetOSVersion() (osVersion, osKernel string) {
}
}
friendlyName := getRegistryVersionString("ReleaseId")
if osVersion != "" && friendlyName != "" {
if osVersion != "" {
// Include the friendly-name of the version, which is typically what is referred to.
// Until Windows 10 version 2004 (May 2020) this can be found from registry entry
// ReleaseID, after that we must use entry DisplayVersion (ReleaseId is stuck at 2009).
// Source: https://ss64.com/nt/ver.html
friendlyName := getRegistryVersionString("DisplayVersion")
if friendlyName == "" {
friendlyName = getRegistryVersionString("ReleaseId")
}
if friendlyName != "" {
osVersion += " " + friendlyName
}
}
updateRevision := getRegistryVersionInt("UBR")
if osKernel != "" && updateRevision != 0 {