策略配置 Microsoft Edge、Google Chrome 是否启用QUIC实验流式传输控制协议

 使用方法:

SupportExperimentalQuicProtocol = false;  // 禁用两款浏览器使用QUIC协议传输流媒体

SupportExperimentalQuicProtocol = true; // 允许两款浏览器使用QUIC协议传输流媒体

        private const string EXPERIMENTALQUICPROTOCOL_POLICIES_CHROME = @"Software\Policies\Google\Chrome";
        private const string EXPERIMENTALQUICPROTOCOL_POLICIES_EDGE = @"Software\Policies\Microsoft\Edge";
        public static bool SupportExperimentalQuicProtocol
        {
            get
            {
                return
                    IsSupportExperimentalQuicProtocol(EXPERIMENTALQUICPROTOCOL_POLICIES_EDGE) ||
                    IsSupportExperimentalQuicProtocol(EXPERIMENTALQUICPROTOCOL_POLICIES_CHROME);
            }
            set
            {
                SetSupportExperimentalQuicProtocol(EXPERIMENTALQUICPROTOCOL_POLICIES_EDGE, value);
                SetSupportExperimentalQuicProtocol(EXPERIMENTALQUICPROTOCOL_POLICIES_CHROME, value);
            }
        }
        private static void SetSupportExperimentalQuicProtocol(string key, bool value)
        {
            RegistryKey rk = null;
            try
            {
                rk = Registry.CurrentUser.CreateSubKey(key,
                    RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryOptions.Volatile);
            }
            catch (Exception)
            {
                try
                {
                    rk = Registry.CurrentUser.OpenSubKey(key);
                }
                catch (Exception) { }
            }
            using (rk)
            {
                if (rk != null)
                {
                    try
                    {
                        rk.SetValue("QuicAllowed", value ? 1 : 0);
                    }
                    catch (Exception) { }
                }
            }
        }
        private static bool IsSupportExperimentalQuicProtocol(string key)
        {
            RegistryKey rk = null;
            try
            {
                using (rk = Registry.CurrentUser.OpenSubKey(key, false))
                {
                    int r = 0;
                    try
                    {
                        object v = rk.GetValue("QuicAllowed");
                        r = Convert.ToInt32(v);
                    }
                    catch (Exception)
                    {
                        return true;
                    }
                    return r != 0;
                }
            }
            catch (Exception)
            {
                return true;
            }
        }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值