Skip to content

Instantly share code, notes, and snippets.

@NaniteFactory
Last active April 24, 2024 17:58
Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save NaniteFactory/0bd94e84bbe939cda7201374a0c261fd to your computer and use it in GitHub Desktop.
Save NaniteFactory/0bd94e84bbe939cda7201374a0c261fd to your computer and use it in GitHub Desktop.
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
Copy link

nice ! 💯

@ydcool
Copy link

ydcool commented Oct 6, 2020

cool

@nzkyyds
Copy link

nzkyyds commented Mar 4, 2022

牛牛牛

@cuppacoffe
Copy link

mwah

@FaltoGH
Copy link

FaltoGH commented Apr 24, 2024

icy

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