5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 04:40:41 +08:00

Merge pull request #3891 from ronen25/master

Fix Windows 11 identification in `wails doctor`
This commit is contained in:
Lea Anthony 2025-03-02 10:48:03 +11:00 committed by GitHub
commit dbf7bba69f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 43 additions and 4 deletions

View File

@ -2,12 +2,13 @@ package main
import (
"fmt"
"github.com/wailsapp/wails/v2/internal/shell"
"runtime"
"runtime/debug"
"strconv"
"strings"
"github.com/wailsapp/wails/v2/internal/shell"
"github.com/pterm/pterm"
"github.com/jaypipes/ghw"
@ -78,6 +79,7 @@ func diagnoseEnvironment(f *flags.Doctor) error {
{pterm.Bold.Sprint("OS"), info.OS.Name},
{pterm.Bold.Sprint("Version"), info.OS.Version},
{pterm.Bold.Sprint("ID"), info.OS.ID},
{pterm.Bold.Sprint("Branding"), info.OS.Branding},
{pterm.Bold.Sprint("Go Version"), runtime.Version()},
{pterm.Bold.Sprint("Platform"), runtime.GOOS},
{pterm.Bold.Sprint("Architecture"), runtime.GOARCH},

View File

@ -2,9 +2,10 @@ package operatingsystem
// OS contains information about the operating system
type OS struct {
ID string
Name string
Version string
ID string
Name string
Version string
Branding string
}
// Info retrieves information about the current platform

View File

@ -4,10 +4,44 @@ package operatingsystem
import (
"fmt"
"strings"
"syscall"
"unsafe"
"golang.org/x/sys/windows"
"golang.org/x/sys/windows/registry"
)
func stripNulls(str string) string {
// Split the string into substrings at each null character
substrings := strings.Split(str, "\x00")
// Join the substrings back into a single string
strippedStr := strings.Join(substrings, "")
return strippedStr
}
func mustStringToUTF16Ptr(input string) *uint16 {
input = stripNulls(input)
result, err := syscall.UTF16PtrFromString(input)
if err != nil {
panic(err)
}
return result
}
func getBranding() string {
var modBranding = syscall.NewLazyDLL("winbrand.dll")
var brandingFormatString = modBranding.NewProc("BrandingFormatString")
windowsLong := mustStringToUTF16Ptr("%WINDOWS_LONG%\x00")
ret, _, _ := brandingFormatString.Call(
uintptr(unsafe.Pointer(windowsLong)),
)
return windows.UTF16PtrToString((*uint16)(unsafe.Pointer(ret)))
}
func platformInfo() (*OS, error) {
// Default value
var result OS
@ -27,6 +61,7 @@ func platformInfo() (*OS, error) {
result.Name = productName
result.Version = fmt.Sprintf("%s (Build: %s)", releaseId, currentBuild)
result.ID = displayVersion
result.Branding = getBranding()
return &result, key.Close()
}

View File

@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Added option to set window class name on Windows. Added in [PR](https://github.com/wailsapp/wails/pull/3828) by @APshenkin
- Added "Branding" section to `wails doctor` to correctly identify Windows 11 [#3891](https://github.com/wailsapp/wails/pull/3891) by [@ronen25](https://github.com/ronen25)
### Fixed
- Fixed dev mode logging bug by @attperac in [#3972](https://wailsapp/wails/pull/3972)