首页 > 开发 > 综合 > 正文

C#应用:获取cpu序列号,硬盘ID,网卡MAC地址

2024-07-21 02:28:52
字体:
来源:转载
供稿:网友

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();
   }
  }



收集最实用的网页特效代码!

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表