日期:2014-05-19  浏览次数:20990 次

如何获取网卡真实的MAC地址??????????????????????
有些用户会改变自己的网卡MAC地址,如何读取网卡的真实MAC地址而不是用户更改后的网卡MAC地址????谢谢!!!!!!!!!!!!!!!!!!!!

------解决方案--------------------
wmi
------解决方案--------------------
@_@
------解决方案--------------------
我虽然没有回答您的问题,但也帮您顶了下,求您给小女几分好吗?我非专业,但需要点分提问啊!

呵呵,谢谢!!
------解决方案--------------------
using System;
using System.Management;

namespace HTSoft.Common.Register
{
/// <summary>
/// 计算机信息类
/// </summary>
internal class Computer
{
public string CpuID;
public string MacAddress;
public string DiskID;
public string IpAddress;
public string LoginUserName;
public string ComputerName;
public string SystemType;
public string TotalPhysicalMemory; //单位:M
private static Computer _instance;

internal static Computer Instance()
{
if (_instance == null)
_instance = new Computer();
return _instance;
}

internal Computer()
{
CpuID = GetCpuID();
MacAddress = GetMacAddress();
DiskID = GetDiskID();
IpAddress = GetIPAddress();
LoginUserName = GetUserName();
SystemType = GetSystemType();
TotalPhysicalMemory = GetTotalPhysicalMemory();
ComputerName = GetComputerName();
}
string GetCpuID()
{
try
{
//获取CPU序列号代码
string cpuInfo = " ";//cpu序列号
ManagementClass mc = new ManagementClass( "Win32_Processor ");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
cpuInfo = mo.Properties[ "ProcessorId "].Value.ToString();
}
moc = null;
mc = null;
return cpuInfo;
}
catch
{
return "unknow ";
}
finally
{
}

}
string GetMacAddress()
{
try
{
//获取网卡硬件地址
string mac = " ";
ManagementClass mc = new ManagementClass( "Win32_NetworkAdapterConfiguration ");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if ((bool)mo[ "IPEnabled "] == true)
{
mac = mo[ "MacAddress "].ToString();
break;
}
}
moc = null;
mc = null;
return mac;
}
catch
{
return "unknow ";
}
finally
{
}

}
string GetIPAddress()
{
try
{
//获取IP地址
string st = " ";