Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
microsoft.public.dotnet.framework.remoting
Enumerating Network Cards and IP Addresses
Mark Hollander
10/19/2004 8:22:00 AM
Hi,
Is there a way to enumerate the Network cards that have been installed
on the system and get their IP Addresses using the .Net framework
without making any API calls.
Thank You
Mark Hollander
*** Sent via Developersdex
http://www.develop...
***
Don't just participate in USENET...get rewarded for it!
1 Answer
Ken Kolda
10/19/2004 3:40:00 PM
0
You can get all of this information using the System.Management classes,
which basically provide a wrapper around thw WMI APIs. In particular, you'd
want to query against the Win32_NetworkAdapterConfiguration class:
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_networkadapterconfigu...
For example, the following code will produce a list of the MAC Addresses for
all NIC cards on the local machine.
//////// CODE START
ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * FROM
Win32_NetworkAdapterConfiguration") ;
ManagementObjectCollection queryCollection = query.Get();
ArrayList addresses = new ArrayList();
foreach (ManagementObject mo in queryCollection)
{
if (mo["MacAddress"] != null)
addresses.Add(mo["MacAddress"].ToString());
}
macAddresses = (string[]) addresses.ToArray(typeof(string));
//////// CODE END
The link above shows you all the properties for the
Win32_NetworkAdapterConfiguration object, which includes a property for
their IPAddresses.
Hope that helps -
Ken
"Mark Hollander" <mark@atcom.co.za> wrote in message
news:elRGnSbtEHA.1272@TK2MSFTNGP12.phx.gbl...
> Hi,
>
> Is there a way to enumerate the Network cards that have been installed
> on the system and get their IP Addresses using the .Net framework
> without making any API calls.
>
> Thank You
> Mark Hollander
>
> *** Sent via Developersdex
http://www.develop...
***
> Don't just participate in USENET...get rewarded for it!
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Enumerating Network Cards and IP Addresses
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password