使用方法:
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;
}
}