29 Temmuz 2014 Salı

Chrome Version Öğrenme

private static void GetChromeVersion()
    {
        string wowNode = string.Empty;
        if (Environment.Is64BitOperatingSystem) wowNode = @"Wow6432Node\";
 
        RegistryKey regKey = Registry.LocalMachine;
        RegistryKey keyPath = regKey.OpenSubKey(@"Software\" + wowNode + @"Google\Update\Clients");
 
        if (keyPath == null)
        {
            regKey = Registry.CurrentUser;
            keyPath = regKey.OpenSubKey(@"Software\" + wowNode + @"Google\Update\Clients");
        }     
 
        if (keyPath == null)
        {
            regKey = Registry.LocalMachine;
            keyPath = regKey.OpenSubKey(@"Software\Google\Update\Clients");
        }
 
        if (keyPath == null)
        {
            regKey = Registry.CurrentUser;
            keyPath = regKey.OpenSubKey(@"Software\Google\Update\Clients");
        }
 
        if (keyPath != null)
        {
            string[] subKeys = keyPath.GetSubKeyNames();
            foreach (string subKey in subKeys)
            {
                object value = keyPath.OpenSubKey(subKey).GetValue("name");
                bool found = false;
                if (value != null)
                    found =
                        value.ToString()
                             .Equals("Google Chrome", StringComparison.InvariantCultureIgnoreCase);
                if (found)
                {
                    Console.WriteLine("chrome-" + keyPath.OpenSubKey(subKey).GetValue("pv"));
                    break;
                }
            }
        }
        else
        {
            Console.WriteLine("registry key not found for chrome");
        }
    }