C#中如何获取当前的活动网络

图片说明

想在C#中获取这个信息,请问大佬们有没有啥好方法,或者有没有啥API调用能获取到。

System.Net.NetworkInformation.NetworkInterface[] interfaces = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();
foreach (System.Net.NetworkInformation.NetworkInterface ni in interfaces)
{
    if (ni.OperationalStatus == System.Net.NetworkInformation.OperationalStatus.Up)
    {
        Console.WriteLine(ni.Name);
    }
}