messagebox.go 611 B

123456789101112131415161718192021222324252627
  1. package cmd
  2. import (
  3. "syscall"
  4. "unsafe"
  5. )
  6. // @title MsgBox
  7. // @description 弹出提示框
  8. // @param title 提示框标题,content 提示框内容
  9. // @return
  10. func MsgBox(title, content string) {
  11. user32dll, _ := syscall.LoadLibrary("user32.dll")
  12. user32 := syscall.NewLazyDLL("user32.dll")
  13. MessageBoxW := user32.NewProc("MessageBoxW")
  14. MessageBoxW.Call(IntPtr(0), StrPtr(content), StrPtr(title), IntPtr(0))
  15. defer syscall.FreeLibrary(user32dll)
  16. }
  17. func IntPtr(n int) uintptr {
  18. return uintptr(n)
  19. }
  20. func StrPtr(s string) uintptr {
  21. return uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(s)))
  22. }