[Mono-dev] get mac address using system.management

Gonzalo Paniagua Javier gonzalo.mono at gmail.com
Mon Apr 13 17:13:41 EDT 2009


On Mon, 2009-04-13 at 10:50 -0700, tooty wrote:
> hi all,
> i used to get mac address of Ethernet adapter under windows, using the
> following code:
> 
> //
> Dim mc As System.Management.ManagementClass
>       Dim mo As ManagementObject
>       mc = New ManagementClass("Win32_NetworkAdapterConfiguration")
>       Dim moc As ManagementObjectCollection = mc.GetInstances()
>       For Each mo In moc
>          If mo.Item("IPEnabled") = True Then
>             ListBox1.Items.Add("MAC address " &
> mo.Item("MacAddress").ToString())
>          End If
>       Next
> //
> now i have to do the same under Linux system.
> 
> now, its obvious i wont find  "Win32_NetworkAdapterConfiguration" under
> managementclass on Linux.
> 
> so, can anyone tell me what is the wright method of managementclass that
> will let me get the network adapter properties?

You can use the classes in System.Net.NetworkInformation (see
NetworkInterface.GetPhysicalAddress). This will work on MS.NET too.

-Gonzalo




More information about the Mono-devel-list mailing list