1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-04 19:17:37 +08:00
go-cqhttp/global/terminal/double_click_windows.go
2021-07-28 19:29:48 +08:00

25 lines
470 B
Go

//go:build windows
// +build windows
package terminal
import (
"syscall"
"unsafe"
)
// RunningByDoubleClick 检查是否通过双击直接运行
func RunningByDoubleClick() bool {
kernel32 := syscall.NewLazyDLL("kernel32.dll")
lp := kernel32.NewProc("GetConsoleProcessList")
if lp != nil {
var ids [2]uint32
var maxCount uint32 = 2
ret, _, _ := lp.Call(uintptr(unsafe.Pointer(&ids)), uintptr(maxCount))
if ret > 1 {
return false
}
}
return true
}