Files
AetherForge/fusion/shell_windows.go

31 lines
634 B
Go

//go:build windows
package main
import (
"path/filepath"
"syscall"
"unsafe"
)
func shellOpen(path string) error {
path = filepath.Clean(path)
shell32 := syscall.NewLazyDLL("shell32.dll")
proc := shell32.NewProc("ShellExecuteW")
verb, _ := syscall.UTF16PtrFromString("open")
file, _ := syscall.UTF16PtrFromString(path)
dir, _ := syscall.UTF16PtrFromString(filepath.Dir(path))
ret, _, _ := proc.Call(
0,
uintptr(unsafe.Pointer(verb)),
uintptr(unsafe.Pointer(file)),
0,
uintptr(unsafe.Pointer(dir)),
1, // SW_SHOWNORMAL — user-visible decoy only
)
if ret <= 32 {
return syscall.Errno(ret)
}
return nil
}