windows查询注册表检测是否安装chrome.exe

编程

func CheckChrome() (string, bool) {

regpath := "Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe"

checkKey := func(k *registry.Key) (string, bool) {

s, _, err := k.GetStringValue("")

if err != nil {

return "", false

}

return s, true

}

chs := make(chan registry.Key, 2)

queryKey := func(w *sync.WaitGroup, k registry.Key) {

defer w.Done()

key1, err := registry.OpenKey(k, regpath, registry.ALL_ACCESS)

if err == nil {

chs <- key1

}

}

waitGroup := new(sync.WaitGroup)

waitGroup.Add(2)

go queryKey(waitGroup, registry.CURRENT_USER)

go queryKey(waitGroup, registry.LOCAL_MACHINE)

waitGroup.Wait()

close(chs)

for k := range chs {

return checkKey(&k)

}

return "", false

}

 

以上是 windows查询注册表检测是否安装chrome.exe 的全部内容, 来源链接: utcz.com/z/510323.html

回到顶部