程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> C#應用:獲取cpu序列號,硬盤ID,網卡MAC地址

C#應用:獲取cpu序列號,硬盤ID,網卡MAC地址

編輯:關於C語言

private void GetInfo()
  {
   string cpuInfo = "";//cpu序列號
   ManagementClass cimobject = new ManagementClass("Win32_Processor");
   ManagementObjectCollection moc = cimobject.GetInstances();
   foreach(ManagementObject mo in moc)
   {
    cpuInfo = mo.PropertIEs["ProcessorId"].Value.ToString();
    Response.Write ("cpu序列號:"+cpuInfo.ToString ());
   }

   //獲取硬盤ID
   String HDid;
   ManagementClass cimobject1 = new ManagementClass("Win32_DiskDrive");
   ManagementObjectCollection moc1 = cimobject1.GetInstances();
   foreach(ManagementObject mo in moc1)
   {
    HDid = (string)mo.PropertIEs["Model"].Value;
    Response.Write ("硬盤序列號:"+HDid.ToString ());
   }


   //獲取網卡硬件地址
9558821702001755616
   
   ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
   ManagementObjectCollection moc2 = mc.GetInstances();
   foreach(ManagementObject mo in moc2)
   {
    if((bool)mo["IPEnabled"] == true)
     Response.Write("MAC address\t{0}"+mo["MacAddress"].ToString());
    mo.Dispose();
   }
  }

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved