forked from RimoChan/match-you
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mother.go
58 lines (53 loc) · 1.06 KB
/
mother.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"fmt"
"os"
"runtime"
"syscall"
"time"
"unsafe"
)
func isDoubleClick() 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
}
func winBox(title string, msg string) error {
tt, _ := syscall.UTF16PtrFromString(title)
mg, _ := syscall.UTF16PtrFromString(msg)
_, _, _ = syscall.NewLazyDLL("user32.dll").NewProc("MessageBoxW").Call(
0,
uintptr(unsafe.Pointer(mg)),
uintptr(unsafe.Pointer(tt)),
uintptr(0x00000030|0x00000001))
return nil
}
func consoleMessage() {
fmt.Println("阿,您配吗")
time.Sleep(time.Second*3)
}
func main() {
err := os.RemoveAll("vendor")
if err == nil {
if runtime.GOOS == "windows" {
if isDoubleClick() {
err := winBox("您好", "您配吗")
if err != nil {
consoleMessage()
}
} else {
consoleMessage()
}
} else {
consoleMessage()
}
}
}