go mod update

master v0.0.2
兔子 3 years ago
parent bcca944297
commit dd0f4f8c20
Signed by: b612
GPG Key ID: 481225A74DEB62A1

@ -3,7 +3,9 @@ module b612.me/wincmd
go 1.16
require (
b612.me/stario v0.0.5
b612.me/stario v0.0.7
b612.me/win32api v0.0.1
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5
golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064 // indirect
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
)

@ -1,16 +1,22 @@
b612.me/stario v0.0.5 h1:Q1OGF+8eOoK49zMzkyh80GWaMuknhey6+PWJJL9ZuNo=
b612.me/stario v0.0.5/go.mod h1:or4ssWcxQSjMeu+hRKEgtp0X517b3zdlEOAms8Qscvw=
b612.me/stario v0.0.7 h1:QbQcsHCVLE6vRgVrPN4+9DGiSaC6IWdtm4ClL2tpMUg=
b612.me/stario v0.0.7/go.mod h1:or4ssWcxQSjMeu+hRKEgtp0X517b3zdlEOAms8Qscvw=
b612.me/win32api v0.0.1 h1:vLFB1xhO6pd9+zB2EyaapKB459Urv3v+C1YwgwOFEWo=
b612.me/win32api v0.0.1/go.mod h1:MHu0JBQjzxQ2yxpZPUBbn5un45o67eF5iWKa4Q9e0yE=
golang.org/x/crypto v0.0.0-20220313003712-b769efc7c000 h1:SL+8VVnkqyshUSz5iNnXtrBQzvFF2SkROm6t5RczFAE=
golang.org/x/crypto v0.0.0-20220313003712-b769efc7c000/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064 h1:S25/rfnfsMVgORT4/J61MJ7rdyseOZOyvLIrZEZ7s6s=
golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 h1:y/woIyUBFbpQGKS0u1aHF/40WUDnek3fPOyD08H5Vng=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 h1:OH54vjqzRWmbJ62fjuhxy7AxFFgoHN0/DPc/UrL8cAs=
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

@ -106,10 +106,10 @@ func GetRunningProcess() ([]map[string]string, error) {
return result, nil
}
func IsProcessRunningByPID(pid int) bool {
func IsProcessRunningByPID(pid int) (bool, error) {
pHandle, err := win32api.CreateToolhelp32Snapshot(0x2, 0x0)
if err != nil {
return false
return false, err
}
for {
var proc win32api.PROCESSENTRY32
@ -117,19 +117,19 @@ func IsProcessRunningByPID(pid int) bool {
if err := win32api.Process32Next(pHandle, &proc); err == nil {
bytetmp := int(proc.Th32ProcessID)
if bytetmp == pid {
return true
return true, nil
}
} else {
break
}
}
win32api.CloseHandle(pHandle)
return false
return false, err
}
func IsProcessRunning(name string) bool {
func IsProcessRunning(name string) (bool, error) {
pHandle, err := win32api.CreateToolhelp32Snapshot(0x2, 0x0)
if err != nil {
return false
return false, err
}
for {
var proc win32api.PROCESSENTRY32
@ -144,21 +144,21 @@ func IsProcessRunning(name string) bool {
sakura = append(sakura, v)
}
if strings.ToLower(strings.TrimSpace(string(sakura))) == strings.ToLower(strings.TrimSpace(name)) {
return true
return true, nil
}
} else {
break
}
}
win32api.CloseHandle(pHandle)
return false
return false, err
}
func GetProcessCount(name string) int {
func GetProcessCount(name string) (int, error) {
var res int = 0
pHandle, err := win32api.CreateToolhelp32Snapshot(0x2, 0x0)
if err != nil {
return 0
return 0, err
}
for {
var proc win32api.PROCESSENTRY32
@ -180,7 +180,7 @@ func GetProcessCount(name string) int {
}
}
win32api.CloseHandle(pHandle)
return res
return res, err
}
func Isas() bool {
@ -191,7 +191,7 @@ func Isas() bool {
return true
}
func StartProcess(appPath, cmdLine, wordDir string, runas bool, ShowWindow int) bool {
func StartProcess(appPath, cmdLine, wordDir string, runas bool, ShowWindow int) error {
var cst string
if runas {
cst = "runas"
@ -199,12 +199,10 @@ func StartProcess(appPath, cmdLine, wordDir string, runas bool, ShowWindow int)
cst = "open"
}
r := win32api.ShellExecute(0, cst, appPath, cmdLine, wordDir, ShowWindow)
if r != nil {
return false
return r
}
return true
}
func StartProcessWithPID(appPath, cmdLine, workDir string, runas bool, ShowWindow int) int {
func StartProcessWithPID(appPath, cmdLine, workDir string, runas bool, ShowWindow int) (int, error) {
var sakura win32api.SHELLEXECUTEINFOW
sakura.Hwnd = 0
sakura.NShow = ShowWindow
@ -220,9 +218,9 @@ func StartProcessWithPID(appPath, cmdLine, workDir string, runas bool, ShowWindo
sakura.CbSize = win32api.DWORD(unsafe.Sizeof(sakura))
if err := win32api.ShellExecuteEx(&sakura); err != nil {
return 0
return 0, err
}
return int(win32api.GetProcessId(sakura.HProcess))
return int(win32api.GetProcessId(sakura.HProcess)), nil
}
func AutoRun(key, path string) (bool, error) {
@ -250,13 +248,13 @@ func DeleteAutoRun(key string) (bool, error) {
return true, nil
}
func IsAutoRun(key, path string) bool {
reg, errs := registry.OpenKey(registry.LOCAL_MACHINE, `Software\Microsoft\Windows\CurrentVersion\Run`, registry.ALL_ACCESS)
if errs != nil {
return false
func IsAutoRun(key, path string) (bool, error) {
reg, err := registry.OpenKey(registry.LOCAL_MACHINE, `Software\Microsoft\Windows\CurrentVersion\Run`, registry.ALL_ACCESS)
if err != nil {
return false, err
}
if sa, _, _ := reg.GetStringValue(key); sa == path {
return true
return true, err
}
return false
return false, err
}

Loading…
Cancel
Save