Learn Get MAC address of your system
This sample code shows how to retrieve the MAC address of your computer using C#. Can convert this code to VB.NET easily.
public string GetMACAddress()
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mc.GetInstances();
string MACAddress = String.Empty;
foreach (ManagementObject mo in moc)
if (MACAddress == String.Empty) // only return MAC Address from first card
if ((bool)mo["IPEnabled"] == true) MACAddress = mo["MacAddress"].ToString();
MACAddress = MACAddress.Replace(":", "");
gud info thanks for sharing
Thanks for this information............
But In which namespace have ManagementClass and ManagementObjectCollection classes.
Add the reference System.Management
and Import System.Management namespace;
very useful thanks
Its very help full.
Thanks for providing this snippet. Its very much helpful for me. I will be using it with some other program logic to generate product key. Your code will provide the core.
Thanks once again.
This is not working for me. I have added the namespace : "System.Management;"
It's awesome.Thanks a lot.
the namespace system.management is not avail in vb.net 2003, so i will use this functionality please. help.
I need client machine user name, how can i retrieve the client machine name, i have tried for number of scenarios but when hosted to server nothing will works.