返回 DeepSeek-Reasonix
shell_windows.go
根目录 / internal / sandbox / shell_windows.go
1 //go:build windows
2
3 package sandbox
4
5 import (
6 "golang.org/x/sys/windows/registry"
7 )
8
9 func windowsRegistryGitRoots() []string {
10 var roots []string
11 for _, rootKey := range []registry.Key{registry.LOCAL_MACHINE, registry.CURRENT_USER} {
12 for _, subKey := range []string{
13 `SOFTWARE\GitForWindows`,
14 `SOFTWARE\WOW6432Node\GitForWindows`,
15 `SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Git_is1`,
16 } {
17 k, err := registry.OpenKey(rootKey, subKey, registry.QUERY_VALUE)
18 if err != nil {
19 continue
20 }
21 for _, valName := range []string{"InstallPath", "InstallLocation"} {
22 if val, _, err := k.GetStringValue(valName); err == nil && val != "" {
23 roots = append(roots, val)
24 }
25 }
26 _ = k.Close()
27 }
28 }
29 return roots
30 }
31
31 lines GO