messagebox_windows.go 482 B

12345678910111213141516171819
  1. //+build windows
  2. package lorca
  3. import (
  4. "syscall"
  5. "unsafe"
  6. )
  7. func messageBox(title, text string) bool {
  8. user32 := syscall.NewLazyDLL("user32.dll")
  9. messageBoxW := user32.NewProc("MessageBoxW")
  10. mbYesNo := 0x00000004
  11. mbIconQuestion := 0x00000020
  12. idYes := 6
  13. ret, _, _ := messageBoxW.Call(0, uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(text))),
  14. uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(title))), uintptr(uint(mbYesNo|mbIconQuestion)))
  15. return int(ret) == idYes
  16. }