//go:build windows

package main

import (
	"syscall"
	"unsafe"
)

const (
	MB_ICONERROR       = 0x10
	MB_ICONINFORMATION = 0x40
)

var (
	user32          = syscall.NewLazyDLL("user32.dll")
	procMessageBoxW = user32.NewProc("MessageBoxW")
)

func showError(title, message string) {
	messageBox(title, message, MB_ICONERROR)
}

func messageBox(title, message string, flags uint) {
	titlePtr, _ := syscall.UTF16PtrFromString(title)
	messagePtr, _ := syscall.UTF16PtrFromString(message)
	procMessageBoxW.Call(
		0,
		uintptr(unsafe.Pointer(messagePtr)),
		uintptr(unsafe.Pointer(titlePtr)),
		uintptr(flags),
	)
}
