Adrian wrote:
Hi!
Use the code below:
System.Management.SelectQuery sq = new
System.Management.SelectQuery("Win32_NetworkAdapte rConfiguration",
"IPEnabled='TRUE'");
System.Management.ManagementObjectSearcher searcher = new
System.Management.ManagementObjectSearcher(sq);
foreach (System.Management.ManagementObject mos in searcher.Get())
{
MessageBox.Show(mos.GetPropertyValue("MACAddress") .ToString());
}
Hope that helps.
Best regards, Adrian.
thanks, i've found another way:
ManagementObjectSearcher query = null;
ManagementObjectCollection queryCollection = null;
try
{
query = new ManagementObjectSearcher("SELECT * FROM
Win32_NetworkAdapterConfiguration") ;
queryCollection = query.Get();
foreach( ManagementObject mo in queryCollection )
{
if((bool)mo["IPEnabled"] == true)
{
Console.WriteLine(mo.GetText(TextFormat.Mof));
Console.WriteLine(mo["MacAddress"]);
}
}
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}