<summary>///Machine code
</summary>
public class Machinecode
{
<summary>
Get CPU Serial Number
</summary>
<returns> string </returns>
public string Getcpuinfo ()
{
String cpuInfo = "";
using (ManagementClass cimobject = new ManagementClass ("Win32_Processor"))
{
Managementobjectcollection MOC = Cimobject. GetInstances ();
foreach (ManagementObject mo in MOC)
{
CpuInfo = mo. properties["Processorid"]. Value.tostring ();
Mo. Dispose ();
}
}
return cpuinfo.tostring ();
}
<summary>
Get the hard drive ID
</summary>
<returns> string </returns>
public string Gethdid ()
{
String HDid = "";
using (ManagementClass Cimobject1 = new ManagementClass ("Win32_DiskDrive"))
{
Managementobjectcollection Moc1 = Cimobject1. GetInstances ();
foreach (ManagementObject mo in Moc1)
{
HDid = (string) mo. properties["Model"]. Value;
Mo. Dispose ();
}
}
return hdid.tostring ();
}
<summary>
Get the NIC hardware address
</summary>
<returns> string </returns>
public string getmoaddress ()
{
String moaddress = "";
using (ManagementClass mc = new ManagementClass ("Win32_NetworkAdapterConfiguration"))
{
Managementobjectcollection MOC2 = MC. GetInstances ();
foreach (ManagementObject mo in moc2)
{
if ((bool) mo["ipenabled"] = = True)
moaddress = mo["MacAddress"]. ToString ();
Mo. Dispose ();
}
}
return moaddress.tostring ();
}
}
C # Get computer CPU hard disk card information