usingSystem;usingSystem.Runtime.InteropServices;usingSystem.Management;namespacehardware{///Summary///a summary description of the Hardware_mac. /// /Summary Public classhardwareinfo{//Take machine name Public stringgethostname () {returnSystem.Net.Dns.GetHostName ();}//Take CPU number Public StringGetcpuid () {Try{ManagementClass mc=NewManagementClass (win32_processor); Managementobjectcollection MOC=MC. GetInstances ();StringStrcpuid =Null;foreach (managementobject moinchMOC) {Strcpuid=mo. Properties[processorid]. Value.tostring (); break;}returnStrcpuid;}Catch{return ;}}//EndMethod//take the first hard drive number Public StringGetharddiskid () {Try{ManagementObjectSearcher Searcher=NewManagementObjectSearcher (SELECT*from Win32_physicalmedia);StringStrharddiskid =Null;foreach (managementobject moinchSearcher. Get ()) {Strharddiskid=Mo[serialnumber]. ToString (). Trim (); break;}returnStrharddiskid;
The above is the class to get the computer information, build a class in VS, then build the DLL can be used in the platform
Original address: http://bbs.delit.cn/thread-584-1-1.html
Reprint please specify the source:
Author: metric Technology www. Delit. cn
Share a C # class that reads computer information