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:
commit
dbf7bba69f
@ -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},
|
||||
|
@ -5,6 +5,7 @@ type OS struct {
|
||||
ID string
|
||||
Name string
|
||||
Version string
|
||||
Branding string
|
||||
}
|
||||
|
||||
// Info retrieves information about the current platform
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user