Obtain the CPU serial number, hard disk ID, and nic MAC address.
Private void getinfo () { String cpuinfo = ""; // CPU serial number Managementclass cimobject = new managementclass ("win32_processor "); Managementobjectcollection MOC = cimobject. getinstances (); Foreach (managementobject Mo in MoC) { Cpuinfo = Mo. properties ["processorid"]. value. tostring (); Response. Write ("CPU serial number:" + cpuinfo. tostring ()); } // Obtain the hard disk 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 ("hard disk serial number:" + Hdid. tostring ()); } // Obtain the hardware address of the NIC
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 (); } } |