C# retreiving neworks card serial number

As a quick sample create a new project and add a listbox, at the top of the file do a
C#:
using system.Management
and also add a reference to system.Management.dll

then paste the following code into the form
C#:
private void Form1_Load(object sender, System.EventArgs e)
{
ManagementClass Netconfig = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection Nics = Netconfig.GetInstances();
foreach(ManagementObject Nic in Nics)
	{
	if((bool)Nic["IPEnabled"] == true)
	listBox1.Items.Add(string.Format("MAC address\t{0}",  Nic["MacAddress"].ToString()));
	Nic.Dispose();
	}
}
 
Last edited:
Back
Top