1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-04 11:07:39 +08:00

fix: linkname

This commit is contained in:
源文雨 2023-03-02 15:08:50 +08:00
parent c3840a5988
commit 04c4446496
3 changed files with 11 additions and 19 deletions

View File

@ -9,7 +9,7 @@ import (
"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())
}

View File

@ -11,28 +11,19 @@ import (
"github.com/Mrs4s/go-cqhttp/internal/base"
)
var (
//go:linkname modkernel32 golang.org/x/sys/windows.modkernel32
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)
func setConsoleTitle(title string) error {
p0, err := syscall.UTF16PtrFromString(title)
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 {
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()))
}

View File

@ -14,6 +14,7 @@ import (
)
func main() {
terminal.SetTitle()
gocq.InitBase()
_ = terminal.DisableQuickEdit()
_ = terminal.EnableVT100()