日期:2014-05-17 浏览次数:20913 次
加入命名空间:
using System.Management;
/// <summary>
/// //获取CPU序列号代码
/// </summary>
/// <returns></returns>
string GetCpuID()
{
try
{
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 "cpu序列号:" + cpuInfo;
}
catch { return "unknow"; }
finally { }
}
/// <summary>
/// 获取网卡硬件地址
/// </summary>
/// <returns></returns>
string GetMacAddress()
{
try
{
//获取网卡硬件地址
string mac = "";
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
&n