From 70a7c4edba281122c05ef46e9efffe5309ef8448 Mon Sep 17 00:00:00 2001 From: Kurenai Date: Sun, 17 Oct 2021 00:02:28 +0800 Subject: Bump to 3.1.1 --- cmd/title_windows.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 cmd/title_windows.go (limited to 'cmd/title_windows.go') diff --git a/cmd/title_windows.go b/cmd/title_windows.go new file mode 100644 index 0000000..fc40785 --- /dev/null +++ b/cmd/title_windows.go @@ -0,0 +1,21 @@ +//go:build windows +package main + +import ( + "syscall" + "unsafe" +) + +func setWindowTitle(title string) { + kernel32, err := syscall.LoadLibrary("kernel32.dll") + if err == nil { + defer syscall.FreeLibrary(kernel32) + setConsoleTitle, err := syscall.GetProcAddress(kernel32, "SetConsoleTitleW") + if err == nil { + ptr, err := syscall.UTF16PtrFromString(title) + if err == nil { + syscall.Syscall(setConsoleTitle, 1, uintptr(unsafe.Pointer(ptr)), 0, 0) + } + } + } +} -- cgit v1.2.1