mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-04 19:17:37 +08:00
fix: linkname
This commit is contained in:
parent
c3840a5988
commit
04c4446496
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/Mrs4s/go-cqhttp/internal/base"
|
"github.com/Mrs4s/go-cqhttp/internal/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
// SetTitle 设置标题为 go-cqhttp `版本` `版权`
|
||||||
// 设置标题
|
func SetTitle() {
|
||||||
fmt.Printf("\033]0;go-cqhttp "+base.Version+" © 2020 - %d Mrs4s"+"\007", time.Now().Year())
|
fmt.Printf("\033]0;go-cqhttp "+base.Version+" © 2020 - %d Mrs4s"+"\007", time.Now().Year())
|
||||||
}
|
}
|
||||||
|
@ -11,28 +11,19 @@ import (
|
|||||||
"github.com/Mrs4s/go-cqhttp/internal/base"
|
"github.com/Mrs4s/go-cqhttp/internal/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
func setConsoleTitle(title string) error {
|
||||||
//go:linkname modkernel32 golang.org/x/sys/windows.modkernel32
|
p0, err := syscall.UTF16PtrFromString(title)
|
||||||
modkernel32 *windows.LazyDLL
|
|
||||||
procSetConsoleTitle = modkernel32.NewProc("SetConsoleTitleW")
|
|
||||||
)
|
|
||||||
|
|
||||||
//go:linkname errnoErr golang.org/x/sys/windows.errnoErr
|
|
||||||
func errnoErr(e syscall.Errno) error
|
|
||||||
|
|
||||||
func setConsoleTitle(title string) (err error) {
|
|
||||||
var p0 *uint16
|
|
||||||
p0, err = syscall.UTF16PtrFromString(title)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
r1, _, e1 := syscall.Syscall(procSetConsoleTitle.Addr(), 1, uintptr(unsafe.Pointer(p0)), 0, 0)
|
r1, _, err := windows.NewLazySystemDLL("kernel32.dll").NewProc("SetConsoleTitleW").Call(uintptr(unsafe.Pointer(p0)))
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
err = errnoErr(e1)
|
return err
|
||||||
}
|
}
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
// SetTitle 设置标题为 go-cqhttp `版本` `版权`
|
||||||
|
func SetTitle() {
|
||||||
_ = setConsoleTitle(fmt.Sprintf("go-cqhttp "+base.Version+" © 2020 - %d Mrs4s", time.Now().Year()))
|
_ = setConsoleTitle(fmt.Sprintf("go-cqhttp "+base.Version+" © 2020 - %d Mrs4s", time.Now().Year()))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user