日期:2014-05-18  浏览次数:21635 次

C#获取的CPU 序列号ID怎么都是一样的?
public string GetCpuInfo() 
  { 
  string strCpu = null; 
  ManagementClass myCpu = new ManagementClass("win32_Processor"); 
  ManagementObjectCollection myCpuConnection = myCpu.GetInstances(); 
  foreach (ManagementObject myObject in myCpuConnection) 
  { 
  strCpu = myObject.Properties["Processorid"].Value.ToString(); 
  break;
  } 
  return strCpu; 
  }


怎么在每台机子上获得都是一样CPU ID?都是 BFEBFBFF0001067A  

是不是方法有错?

------解决方案--------------------
C# code

        /// <summary>
        ///取CPU编号
        /// </summary>
        /// <returns></returns>
        public static string GetCpuID()
        {
            try
            {
                ManagementClass mc = new ManagementClass("Win32_Processor");
                ManagementObjectCollection moc = mc.GetInstances();
                string strCpuID = null;
                foreach (ManagementObject mo in moc)
                {
                    strCpuID = mo.Properties["ProcessorId"].Value.ToString();
                    break;
                }
                return strCpuID;
            }
            catch
            {
                return "";
            }
        }

------解决方案--------------------
http://www.codeproject.com/KB/system/GetHardwareInformation.aspx