You can see this thread Get the IP address of the physical network card ?
(with HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards)
get physical network adapter
Kran2022
406
Reputation points
Hi All Monring,
How can get the lis of network physical adapters? In case of Win32 we can identify PNI ID but what is the equivalent while using NetworkInterface class in c# .net?
From my below code i'm getting only Ethernet in the list but i have both Ethernet and Wireless card in my system; also i would like to exclude all the WAN & Cellulaire networks. Thanks
List<NetworkInterface> macaddresss = GetActualAdapters();
cbox1.Items.Add(macaddresss); //combobox to add the network adapters
public static List<NetworkInterface> GetActualAdapters()
{
try
{
return (from adapter in NetworkInterface.GetAllNetworkInterfaces()
where adapter.NetworkInterfaceType != NetworkInterfaceType.Unknown
where adapter.NetworkInterfaceType != NetworkInterfaceType.Tunnel
where adapter.NetworkInterfaceType != NetworkInterfaceType.Loopback
select adapter).ToList();
}
catch (Exception e)
{
Console.Write("Exception :{0}", e.ToString());
return new List<NetworkInterface>();
}
}
Developer technologies XAML
859 questions
Developer technologies C#
11,570 questions
Accepted answer
-
Castorix31 90,521 Reputation points
2022-12-01T08:55:38.927+00:00