// Info contains all the information about an installation of the webview2 runtime. type Info struct { Location string Name string Version string SilentUninstall string }
// GetInstalledVersion returns the installed version of the webview2 runtime. // If there is no version installed, a blank string is returned. funcGetInstalledVersion() *Info { var regkey = `SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}` if runtime.GOARCH == "386" { regkey = `SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}` }
k, err := registry.OpenKey(registry.LOCAL_MACHINE, regkey, registry.QUERY_VALUE) if err != nil { // Cannot open key = not installed returnnil }
// Info contains all the information about an installation of the webview2 runtime. type Info struct { Location string Name string Version string SilentUninstall string }
funcgetKeyValue(k registry.Key, name string)string { result, _, _ := k.GetStringValue(name) return result }
// GetInstalledVersion returns the installed version of the webview2 runtime. // If there is no version installed, a blank string is returned. funcGetInstalledVersion() (*Info, bool) { bInCurrUser := false var regkey1 = `SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}` var regkey2 = `SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}` k, err := registry.OpenKey(registry.CURRENT_USER, regkey2, registry.QUERY_VALUE) if err != nil { if runtime.GOARCH == "386" { k, err = registry.OpenKey(registry.LOCAL_MACHINE, regkey2, registry.QUERY_VALUE) } else { k, err = registry.OpenKey(registry.LOCAL_MACHINE, regkey1, registry.QUERY_VALUE) } if err != nil { returnnil, bInCurrUser } } else { bInCurrUser = true }