Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Win32 API MessageBox() in Golang
import (
"syscall"
"unsafe"
)
// MessageBox of Win32 API.
func MessageBox(hwnd uintptr, caption, title string, flags uint) int {
ret, _, _ := syscall.NewLazyDLL("user32.dll").NewProc("MessageBoxW").Call(
uintptr(hwnd),
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(caption))),
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(title))),
uintptr(flags))
return int(ret)
}
// MessageBoxPlain of Win32 API.
func MessageBoxPlain(title, caption string) int {
const (
NULL = 0
MB_OK = 0
)
return MessageBox(NULL, caption, title, MB_OK)
}
@Vhenrique05

This comment has been minimized.

Copy link

@Vhenrique05 Vhenrique05 commented Jul 7, 2020

nice ! 💯

@ydcool

This comment has been minimized.

Copy link

@ydcool ydcool commented Oct 6, 2020

cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment