C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Network »

Get MAC address of your system


Posted Date: 08 May 2007    Resource Type: Code Snippets    Category: Network
Author: Vinod SharmaMember Level: Silver    
Rating: 1 out of 5Points: 10



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();
}
mo.Dispose();
}

MACAddress = MACAddress.Replace(":", "");
return MACAddress;
}




Responses

Author: JAYARAJA    08 May 2007Member Level: Gold   Points : 0
gud info thanks for sharing


Author: Raj Kumar Prajapati    27 Aug 2008Member Level: Bronze   Points : 0
IT WORK
THANKS

RAJ PRAJAPAI


Author: Raj Kumar Prajapati    27 Aug 2008Member Level: Bronze   Points : 0
IT WORK
THANKS

RAJ PRAJAPATI




Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Check if a port is open or closed?
Previous Resource: How to monitor the network performance using Performance counter?
Return to Discussion Resource Index
Post New Resource
Category: Network


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use