其他分享
首页 > 其他分享> > golang 定时弹出对话框

golang 定时弹出对话框

作者:互联网

参考:https://studygolang.com/articles/2712

package main

import (
    "syscall"
    "time"
    "unsafe"
)

func IntPtr(n int) uintptr {
    return uintptr(n)
}

func StrPtr(s string) uintptr {
    return uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(s)))
}

// windows下的另一种DLL方法调用
func ShowMessage2(title, text string) {
    user32dll, _ := syscall.LoadLibrary("user32.dll")
    user32 := syscall.NewLazyDLL("user32.dll")
    MessageBoxW := user32.NewProc("MessageBoxW")
    MessageBoxW.Call(IntPtr(0), StrPtr(text), StrPtr(title), IntPtr(0))
    defer syscall.FreeLibrary(user32dll)
}

func main() {
    go func() {
        for {
            ShowMessage2("windows下的另一种DLL方法调用", "HELLO !")
            time.Sleep(3 * time.Second)
        }
    }()
    select {}
}

 

标签:IntPtr,MessageBoxW,对话框,syscall,uintptr,golang,user32,func,定时
来源: https://www.cnblogs.com/pu369/p/12132341.html