CSDN博客

img mdot

(转贴)C#取计算机硬件信息

发表于2004/6/23 9:17:00  685人阅读

分类: .net

//取CPU编号
  private String GetCpuID() {
   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;
  }//end method
 
  //取第一块硬盘编号
  private String GetHardDiskID() {
   ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");
   String strHardDiskID = null ;
   foreach(ManagementObject mo in searcher.Get()) {   
    strHardDiskID = mo["SerialNumber"].ToString().Trim();
    break;         
   }
   return strHardDiskID ;
  }//end method
0 0

相关博文

我的热门文章

img
取 消
img