mirror of
https://github.com/fankes/komari-agent.git
synced 2025-10-19 02:59:23 +08:00
fix: Windows 11 版本识别
This commit is contained in:
@@ -4,6 +4,9 @@
|
||||
package monitoring
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/sys/windows/registry"
|
||||
)
|
||||
|
||||
@@ -19,5 +22,25 @@ func OSName() string {
|
||||
return "Microsoft Windows"
|
||||
}
|
||||
|
||||
// Windows 11
|
||||
majorVersion, _, err := key.GetIntegerValue("CurrentMajorVersionNumber")
|
||||
if err == nil && majorVersion >= 10 {
|
||||
buildNumberStr, _, err := key.GetStringValue("CurrentBuild")
|
||||
if err == nil {
|
||||
buildNumber, err := strconv.Atoi(buildNumberStr)
|
||||
if err == nil && buildNumber >= 22000 { // Windows 11 starts at build 22000
|
||||
// Windows 11 Windows 10 Pro for Workstations
|
||||
edition := strings.Replace(productName, "Windows 10 ", "", 1)
|
||||
return "Windows 11 " + edition
|
||||
}
|
||||
}
|
||||
// DisplayVersion
|
||||
displayVersion, _, err := key.GetStringValue("DisplayVersion")
|
||||
if err == nil && displayVersion >= "21H2" {
|
||||
edition := strings.Replace(productName, "Windows 10 ", "", 1)
|
||||
return "Windows 11 " + edition
|
||||
}
|
||||
}
|
||||
|
||||
return productName
|
||||
}
|
||||
|
Reference in New Issue
Block a user