Here is a code snippet that let's get the MAC address programmatically using C#
public string GetTheMacOfTheCurrentMachine() { string query = "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True"; ManagementObjectSearcher managementObjectSearcher = new ManagementObjectSearcher(query); ManagementObjectCollection managementObjectCollection = managementObjectSearcher.Get(); ManagementObjectCollection.ManagementObjectEnumerator enumerator = managementObjectCollection.GetEnumerator(); enumerator.MoveNext(); string mac = string.Empty; ManagementObject managementObject = enumerator.Current as ManagementObject; mac = managementObject["MacAddress"].ToString(); return mac; }
Thanks.Its very simple code to know the mac address.
ReplyDeleteEffectively, yes
ReplyDelete