Note that there are some explanatory texts on larger screens.

plurals
  1. POFind through which network device user is connected to internet
    text
    copied!<p>Using the code below i will get all network interfaces wich are enabled and functional on the machine.</p> <pre><code>Private netIntrfc As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces() For i As Integer = 0 To netIntrfc.Length - 1 If netIntrfc(i).OperationalStatus = OperationalStatus.Up Then netDevicesList.Items.Add(netIntrfc(i).Name.ToString) End If Next </code></pre> <p>But my problem is how to get the <strong>default</strong> one, the one(<em>ethernet adapter</em>) through wich user is connected to internet?</p> <p>I need to change some settings of default(<em>through wich user is connected to internet</em>) adapter. settings i change through registry so i could sample add same settings for each network interface but that could cause problems and makes no point then :D</p> <p>can anyone help? Thank you! ;)</p> <p>EDITED:</p> <p>for now i have done like code below, so if this can help someone other... :) but if someone have batter solution or more reliable then send please</p> <pre><code>Dim u As UdpClient = New UdpClient(System.Net.Dns.GetHostName, 1) Dim localAddr As IPAddress = CType(u.Client.LocalEndPoint, IPEndPoint).Address Private netIntrfc As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces() For i As Integer = 0 To netIntrfc.Length - 1 If netIntrfc(i).OperationalStatus = OperationalStatus.Up Then For Each uni As NetworkInformation.UnicastIPAddressInformation In ipProps.UnicastAddresses If uni.Address.ToString = localAddr.ToString Then netDevicesList.Items.Add("DEFAULT: " &amp; netIntrfc(i).Name.ToString) DEFDEVID = netIntrfc(i).Id.ToString End If Next netDevicesList.Items.Add(netIntrfc(i).Name.ToString) End If Next </code></pre> <p><strong>Thanks <a href="https://stackoverflow.com/users/638404/thomas-li">Thomas-Li</a> and <a href="https://stackoverflow.com/questions/359596/identifying-active-network-interface-in-net">this post</a></strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload