// Package dll 封装 Windows 系统 API(互斥体防多开、ShellExecute、窗口操作等)。 package dll import ( "github.com/lxn/win" "syscall" ) // ShellExecute 调用系统 ShellExecute 打开文件/网页/程序 // dir 工作目录;file 目标(文件路径、URL 或程序);args 启动参数;hide 是否隐藏窗口 func ShellExecute(dir string, file string, args string, hide bool) bool { lpOperation, _ := syscall.UTF16PtrFromString("open") lpFile, _ := syscall.UTF16PtrFromString(file) lpCwd, _ := syscall.UTF16PtrFromString(dir) lpArgs, _ := syscall.UTF16PtrFromString(args) showCmd := win.SW_SHOWNORMAL if hide { showCmd = win.SW_HIDE } return win.ShellExecute(0, lpOperation, lpFile, lpArgs, lpCwd, showCmd) }