【问题标题】:How to determine if Microsoft Edge is the default browser?如何确定 Microsoft Edge 是否为默认浏览器?
【发布时间】:2015-07-10 00:13:03
【问题描述】:

是否有可靠的编程方式来确定 Microsoft Edge 是默认浏览器?

我知道一种选择是使用IApplicationAssociationRegistration::QueryCurrentDefault 方法返回为http 注册的默认应用程序。虽然不清楚此调用返回的 ProgID 是固定字符串,但它可能不是验证 Edge 确实是默认浏览器的最佳方法。

【问题讨论】:

    标签: microsoft-edge


    【解决方案1】:

    使用下面的代码sn-p。尚未使用 Firefox 或任何其他奇怪的工具进行测试,但您将根据 Windows 10 中的默认浏览器获得以下返回值。

    • Chrome - ChromeHTML
    • 边缘 - AppXq0fevzme2pys62n3e0fbqa7peapykr8v
    • Internet Explorer - IE.HTTP

    下面的代码 sn-p 应该可以工作。在控制台应用程序中测试。如果有人想要 VB 版本,请告诉我。

    using Microsoft.Win32;
    public static class BrowserUtils
    {
        static public string GetSystemDefaultBrowser()
        {
            string _retval = string.Empty;
            const string userChoice = @"Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice";
            using (RegistryKey userChoiceKey = Registry.CurrentUser.OpenSubKey(userChoice))
            {
                if (userChoiceKey == null)
                {
                    _retval = "unknown-> userChoiceKey returned null";
                }
    
                object progIdValue = userChoiceKey.GetValue("Progid");
                if (progIdValue == null)
                {
                    _retval = "unknown->GetValue(Progid) returned null";
                }
                //_retval = String.Format("progId=[{0}]", progIdValue.ToString());
                _retval = progIdValue.ToString();
            }
            return _retval;
        } 
    } 
    

    希望这会有所帮助。坦帕的希利。

    【讨论】:

    • 是的,就像我提到的 IApplicationAssociationRegistration::QueryCurrentDefault 一样,您最终会得到一个用于 Edge 的 ProgID——问题是,ProgID 是否可靠(不太可能改变)。
    • 请联系 msft 网络工作组。从现在起一周后我也会“唠叨”,但不要害怕“敲我”来唠叨。更糟的是,我们可以设置一个 GitHub 存储库或 gist,其中包含 edge 已经/将要成为的值,并围绕它做一些奇怪的事情。
    • 该死的,如果我能得到这个值是否改变的答案。我会继续在本地运行代码,我们可以看看它是否会随着时间而改变。
    • 直到今天,它仍然是 AppXq0fevzme2pys62n3e0fbqa7peapykr8v
    猜你喜欢
    • 2020-10-10
    • 1970-01-01
    • 1970-01-01
    • 2015-07-14
    • 2013-06-25
    • 1970-01-01
    • 1970-01-01
    • 2015-11-19
    • 1970-01-01
    相关资源
    最近更新 更多