Checking if IPv6 is enabled on Windows 7 using C#

前端 未结 3 827
梦谈多话
梦谈多话 2021-01-19 19:06

I am trying to write a program using C# to act as a multipurpose tool for my company. One of the things we would like in this tool is to determine if IPv6 is enabled/binded

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-19 19:33

    I have used this code to test it. Notice that it tests if the IPV6 is enabled, and not if the Network Card is IPV6 compatible:

    public static bool InterfaceHasIpv6Enabled(NetworkInterface @interface)
    {
      try
      {
        var properties = @interface.GetIPProperties().GetIPv6Properties();
        return properties.Index > -999;
      }
      catch (System.Net.NetworkInformation.NetworkInformationException)
      {
        return false;
      }
      catch (Exception ex)
      {
        throw ex;
      }
    }
    

提交回复
热议问题