Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Chrome and Firefox version locally, C#

I am just using regular C# not ASP.NET. I was wondering if I could get the version for Chrome and Firefox. I know for IE you can get the version through registry. From what I can tell Chrome and Firefox do not store that information in registry.

Thanks in advance.

like image 629
Rizowski Avatar asked Jan 13 '13 00:01

Rizowski


People also ask

How do I find my default browser in C#?

The value of HKEY_CURRENT_USER\Software\Clients\StartMenuInternet should give you the default browser name for this user. You can use the name found in HKEY_CURRENT_USER to identify the default browser in HKEY_LOCAL_MACHINE and then find the path that way.

Can I have 2 versions of Chrome installed?

Catalin Cimpanu. Google engineers announced on Monday that Chrome users can now run two different versions of Chrome simultaneously, side-by-side.


1 Answers

If you know the full path of an application, then you can use the System.Diagnostics.FileVersionInfo class to get the version number.

Here's a simple console application that reads the installation paths of Chrome and Firefox from the registry, and outputs their version numbers:

using System;
using System.Diagnostics;
using Microsoft.Win32;

class Program
{
    static void Main(string[] args)
    {
        object path;
        path = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe", "", null);
        if (path != null)
            Console.WriteLine("Chrome: " + FileVersionInfo.GetVersionInfo(path.ToString()).FileVersion);

        path = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe", "", null);
        if (path != null)
            Console.WriteLine("Firefox: " + FileVersionInfo.GetVersionInfo(path.ToString()).FileVersion);
    }
}

Sample output:

Chrome: 24.0.1312.52
Firefox: 16.0.2
like image 110
Michael Liu Avatar answered Oct 08 '22 18:10

Michael Liu