Problem:
Some time you want to develop a software in C# or Vb.net that will run only on specific computer system. for this you use mac address of that system.Solution:
Here the C# code that will fetch mac address.Example:
System.Net.NetworkInformation.NetworkInterface[] nic= System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();String macAddress = string.Empty;
foreach (System.Net.NetworkInformation.NetworkInterface ni in nic)
{
System.Net.NetworkInformation.IPInterfaceProperties properties=ni.GetIPProperties();
macAddress = ni.GetPhysicalAddress().ToString();
if (macAddress != String.Empty) {
MessageBox.Show(macAddress);
return;
}
}
0 comments:
Post a Comment