c# - 如何检测是否安装了 Microsoft Edge?

标签 c# windows registry windows-10 microsoft-edge

我正在编写一个 Windows 窗体应用程序 (c#),我需要检测用户是否在他/她的机器上安装了“Microsoft-Edge”。

我目前正在使用这个注册表位置:

[HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\PackageRepository\Packages\Microsoft.MicrosoftEdge_20.10240.16384.0_neutral__8wekyb3d8bbwe]
"Path"="C:\\Windows\\SystemApps\\Microsoft.MicrosoftEdge_8wekyb3d8bbwe"

在“Microsoft.MicrosoftEdge”之后使用 regex。如果“路径”存在,那么我知道 edge 已安装。

是否有更好的检测边缘的方法?如果我检测到我在 Windows 10 上运行并且默认情况下 Win10 附带 edge 会更好吗?最好的方法是什么?

最佳答案

如果你想让一个小程序获得那个版本号:

static void Main(string[] args)
    {
        string EdgeVersion = string.Empty;
        //open the registry and parse through the keys until you find Microsoft.MicrosoftEdge
        RegistryKey reg = Registry.ClassesRoot.OpenSubKey(@"Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\PackageRepository\Packages");
        if (reg != null)
        {
            foreach (string subkey in reg.GetSubKeyNames())
            {
                if (subkey.StartsWith("Microsoft.MicrosoftEdge"))
                {
                    //RegEx: (Microsoft.MicrosoftEdge_)(\d +\.\d +\.\d +\.\d +)(_neutral__8wekyb3d8bbwe])
                    Match rxEdgeVersion = null;
                    rxEdgeVersion = Regex.Match(subkey, @"(Microsoft.MicrosoftEdge_)(?<version>\d+\.\d+\.\d+\.\d+)(_neutral__8wekyb3d8bbwe)");
                    //just after that value, you need to use RegEx to find the version number of the value in the registry
                    if ( rxEdgeVersion.Success )
                        EdgeVersion = rxEdgeVersion.Groups["version"].Value;
                }
            }
        }

        Console.WriteLine("Edge Version(empty means not found): {0}", EdgeVersion);
        Console.ReadLine();
    }

感谢您提供用于查找版本号的注册表链接。

关于c# - 如何检测是否安装了 Microsoft Edge?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33594401/

相关文章:

c# - 为什么我不能在我的 global.asax 文件夹中添加我的自定义模型联编程序?

c# - 如何调试在生产服务器上无故停止的 C# 服务

c++ - Windows 与 Linux GCC argv[0] 值

c++ - 在 Windows Vista 中写入注册表

delphi - 如何获取子键的名称?

windows - 有没有办法获取所有已安装程序的安装路径?

c# - 删除 ObservableCollection 中的重复项目?在 Windows Phone 7 中

c# - 创建服务引用时 WCF HashSet 更改为 int[]

windows - `explorer.exe .` 在Windows 1903中打开System32目录

python - 在 windows 中使用 python 在 linux 上运行远程 perl 脚本