> thanks for the help and pointing in the right direction,
> rod.
[quoted text clipped - 18 lines]
>>
>> Pete
Following small sample (using WMI/System.Management), dumps some of the
"connected" adapter's configuration info ...
using System;
using System.Management;
class Sample_NeworkSelectQuery
{
enum NetConnectionStatus
{
Connecting = 1,
Connected,
Disconnecting,
Hardware_not_present,
Hardware_disabled,
Hardware_malfunction
}
public static void Main(string[] args)
{
// search for the physical adapters with connection status = 2
(connected)
string q = string.Format("Select DeviceId, NetConnectionStatus ,
NetConnectionID from Win32_NetworkAdapter where PhysicalAdapter='{0}' and
NetConnectionStatus={1}",
true,
(int)NetConnectionStatus.Connected);
SelectQuery selectQuery = new SelectQuery(q);
using(ManagementObjectSearcher adapterSearcher = new
ManagementObjectSearcher(selectQuery))
{
foreach (ManagementObject adapter in adapterSearcher.Get())
{
Console.WriteLine("{0},
{1}",adapter["NetConnectionStatus"].ToString(),
adapter["NetConnectionID"].ToString());
RelatedObjectQuery adapterRelatedQuery =
new RelatedObjectQuery ("associators of
{Win32_NetworkAdapter.DeviceId='" + adapter["DeviceId"]+ "'}");
adapterRelatedQuery.RelatedClass =
"Win32_NetworkAdapterConfiguration";
using(ManagementObjectSearcher adapterConfigSearcher = new
ManagementObjectSearcher(adapterRelatedQuery))
{
foreach (ManagementObject adapterConfig in
adapterConfigSearcher.Get())
{
foreach(string ip in adapterConfig["IPAddress"] as
Array)
Console.WriteLine("\tIpAddress: {0}", ip);
}
}
}
}
}
}
Willy.
rodchar - 14 Mar 2008 05:02 GMT
thanks for the info Willy,
rod.
> > thanks for the help and pointing in the right direction,
> > rod.
[quoted text clipped - 77 lines]
>
> Willy.