Asp. NET gets the CPU serial number, the hard disk serial number ID, obtains the network card number

Source: Internet
Author: User
Tags foreach tostring
Asp.net| Hard Drive

public static void Getcpuinfo (out string cpuInfo)
{
Get CPU Information
String _cpuinfo= "";//CPU information
ManagementClass cimobject = new ManagementClass ("Win32_Processor");
Managementobjectcollection MOC = Cimobject. GetInstances ();
foreach (ManagementObject mo in MOC)
{
_cpuinfo = mo. properties["Processorid"]. Value.tostring ();

}
Cpuinfo=_cpuinfo;
}


Get the hard drive 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)
{
Get the network card hardware address

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



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.