5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 05:00:31 +08:00
wails/v2/internal/system/operatingsystem/os_windows.go
Misite Bao f70d9de366
fix: fix go test errors (#2169)
* fix: fix go test errors

* Add flags to mac test

* Run on all branches

* Update PR workflow

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2022-12-06 06:45:06 +11:00

33 lines
858 B
Go

//go:build windows
package operatingsystem
import (
"fmt"
"golang.org/x/sys/windows/registry"
)
func platformInfo() (*OS, error) {
// Default value
var result OS
result.ID = "Unknown"
result.Name = "Windows"
result.Version = "Unknown"
// Credit: https://stackoverflow.com/a/33288328
// Ignore errors as it isn't a showstopper
key, _ := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE)
productName, _, _ := key.GetStringValue("ProductName")
currentBuild, _, _ := key.GetStringValue("CurrentBuildNumber")
displayVersion, _, _ := key.GetStringValue("DisplayVersion")
releaseId, _, _ := key.GetStringValue("ReleaseId")
result.Name = productName
result.Version = fmt.Sprintf("%s (Build: %s)", releaseId, currentBuild)
result.ID = displayVersion
return &result, key.Close()
}