my question is how to enumerate the ip addresses of all installed Network
interfaces useing the .Net Framework
in plain Win32 i can write:
WSAIoctl(...) to get all the interface params.
How is this don with .Net i have searched through the System.Net Namespace
but found nothing.
PLease let me know if i'm missing something here or if it is (until now) not
possible with the Frameweork then how do i accomplish this with the old
windows api can i still call the Win32 API functions?
Thanks in advance.
Cu Ulrich
using System.Management;
....
....
static void EnumNetworkAdapters() {
query = new ManagementObjectSearcher("SELECT * FROM
Win32_NetworkAdapterConfiguration") ;
ManagementObjectCollection queryCollection = query.Get();
foreach( ManagementObject mo in queryCollection ) {
Console.WriteLine( "'{0}’", mo.ClassPath);
Console.WriteLine( "'{0}’", mo.Options);
Console.WriteLine( "Index\t‘{0}’", mo["Index"]);
Console.WriteLine( "Description\t‘{0}’", mo["Description"]);
Console.WriteLine( "MacAddress\t‘{0}’", mo["MacAddress"]);
if((bool)mo["IPEnabled"] == true) {
string[] addresses = (string[])mo["IPAddress"];
string[] subnets = (string[])mo["IPSubnet"];
Console.WriteLine( "DNS Host\t‘{0}’", mo["DNSHostName"]);
Console.WriteLine( "DNS Domain\t‘{0}’", mo["DNSDomain"]);
foreach(string s in addresses) {
Console.WriteLine( "IP Address ‘{0}’", s);
}
foreach(string s in subnets) {
Console.WriteLine( "IP Subnet ‘{0}’", s);
}
}
}
}
Output (on system running W2K):
'\\SCENIC1\root\cimv2:Win32_NetworkAdapterConfiguration'
'System.Management.ObjectGetOptions'
Index '0'
Description 'Accton EN1207D/EN2242A Series NDIS 5.0 driver'
MacAddress '00:10:B5:81:B5:E1'
DNS Host 'scenic1'
DNS Domain 'pandora.be'
IP Address '192.168.0.2'
IP Subnet '255.255.255.0'
Willy.
"Ulrich Petri" <ul...@gmx.de> wrote in message
news:ut11CKqxAHA.1408@tkmsftngp05...
Thank You!
After converting it to VB.Net it works great for me!
Greets Ulrich