| 12345678910111213141516171819202122232425 |
- package main
- import (
- "os/exec"
- "syscall"
- "unsafe"
- )
- // showMessageBox 调用 Windows MessageBoxW 弹出模态对话框
- func showMessageBox(title, msg string) {
- user32 := syscall.NewLazyDLL("user32.dll")
- msgBox := user32.NewProc("MessageBoxW")
- lpTitle, _ := syscall.UTF16PtrFromString(title)
- lpText, _ := syscall.UTF16PtrFromString(msg)
- // MB_OK | MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST
- const flags = 0x00000000 | 0x00000030 | 0x00010000 | 0x00040000
- msgBox.Call(0, uintptr(unsafe.Pointer(lpText)), uintptr(unsafe.Pointer(lpTitle)), uintptr(flags))
- }
- // runNotepad 调用 notepad.exe 打开指定文件
- func runNotepad(path string) {
- exec.Command("notepad.exe", path).Start()
- }
|