Hi,
Are you getting more than one ?
Do you have more than one nic?
You can check the AdapterType , like this:
ManagementObjectSearcher("select AdapterType, MACAddress from
Win32_NetworkAdapter");
then you can check if the adapter is ethernet, take a look at
Win32_NetworkAdapter class in the MSDN
I dont know of any particular book about WMI, it should exist though.
By the way, my code contained couple of errors
string s = item.Item["MACAddress"];
will give you an error, please check that, the same with item.Item , when it
should say item[""]
I had that example around but it's written in VB
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Peter said:
Ignacio,
Thanks for the tip. Question though, it lists out several MAC address but
only one is my network card's MAC address. Is there any way of filter the
query?
Also, ManagementObjectSearcher and about querying is all new to me. Is
there a book you could recommend that discusses this class?
Thanks again
Peter
Ignacio Machin ( .NET/ C# MVP ) said:
Hi,
ManagementObjectSearcher wmiObj= new ManagementObjectSearcher("select
MACAddress from Win32_NetworkAdapter");
foreach (ManagementObject item in wmiObj.Get())
string s = item.Item["MACAddress"];
Should do it
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Hello,
Thanks for reviewing my question. I would like to obtain the MAC address
of
my network card in C#. Is there any simple API I can call.
Many Thanks
Peter