Getting Chrome and Firefox version locally, C#
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.52Firefox: 16.0.2