获取Chrome和Firefox的版本本地,C# [英] Getting Chrome and Firefox version locally, C#

查看:1706
本文介绍了获取Chrome和Firefox的版本本地,C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是用常规的C#不ASP.NET。我在想,如果我能得到的版本,Chrome和Firefox。我知道你的IE能打通注册表中的版本。从我可以告诉Chrome和Firefox不存储在注册表中的信息。

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.

在此先感谢。

推荐答案

如果您知道某个应用程序的完整路径,那么你可以使用的 System.Diagnostics.FileVersionInfo 类来获得的版本号。

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

下面是一个简单的控制台应用程序读取Chrome和Firefox的安装路径从注册表,并输出其版本号:

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

这篇关于获取Chrome和Firefox的版本本地,C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆