diff options
Diffstat (limited to 'cmd/title_windows.go')
| -rw-r--r-- | cmd/title_windows.go | 21 |
1 files changed, 21 insertions, 0 deletions
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) + } + } + } +} |
