用vb.net如何取得mac地址?我用的是VB 2008。我这样写Dim Wmi As New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration")可总提示我System.Management.ManagementObjectSearcher没有定义。请问是什么原因呢?谢谢!
这是C#的,你可以转换一下 using System.Management; //获取网卡的系列号 private static string GetMacAddress() { string ret = ""; try { ManagementClass cimobject = new ManagementClass("Win32_NetworkAdapterConfiguration"); ManagementObjectCollection moc = cimobject.GetInstances(); if (moc.Count == 0) return ""; else { foreach (ManagementObject mo in moc) { if ((bool)mo["IPEnabled"] == true) { ret = (string)mo.Properties["MacAddress"].Value; break; } } } } catch { ret = ""; } return ret; }