首页 > 编程 > .NET > 正文

ASP.NET获取CPU序列号,硬盘序列号ID,获取网卡编号

2024-07-10 13:05:40
字体:
来源:转载
供稿:网友

public static void getcpuinfo(out string cpuinfo)
{
//得到cpu信息
string _cpuinfo="";//cpu信息
managementclass cimobject = new managementclass("win32_processor");
managementobjectcollection moc = cimobject.getinstances();
foreach(managementobject mo in moc)
{
_cpuinfo = mo.properties["processorid"].value.tostring();

}
cpuinfo=_cpuinfo;
}


 

//获取硬盘id
string _hdinfo="";
managementclass cimobject1 = new managementclass("win32_diskdrive");
managementobjectcollection moc1 = cimobject1.getinstances();
foreach(managementobject mo in moc1)
{
_hdinfo = (string)mo.properties["model"].value;


}
hdinfo=_hdinfo;
}


public static void getmacaddress(out string macaddress)
{
//获取网卡硬件地址

string _macaddress="";
managementclass mc = new managementclass("win32_networkadapterconfiguration");
managementobjectcollection moc2 = mc.getinstances();
foreach(managementobject mo in moc2)
{
if((bool)mo["ipenabled"] == true)
macaddress=mo["macaddress"].tostring();
mo.dispose();
}
macaddress=_macaddress;
}

 

 

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