C # Some ways to get hardware parameters
private static string Getidentifier (String WmiClass, String wmiproperty, String wmimustbetrue) {string result = ""; System.Management.ManagementClass mc = new System.Management.ManagementClass (wmiClass); System.Management.ManagementObjectCollection MOC = MC. GetInstances (); foreach (System.Management.ManagementObject mo in MoC) {if (Mo[wmimustbetrue]. ToString () = "True") {//only get the first one if (result = = "") {try {result = Mo[wmiproperty] . ToString (); Break } Catch {}}} } return result; } private static string Getidentifier (String wmiClass, String wmiproperty) { string result = ""; System.Management.ManagementClass mc = new System.Management.ManagementClass (wmiClass); System.Management.ManagementObjectCollection MOC = MC. GetInstances (); foreach (System.Management.ManagementObject mo in moc) {//only get the first one if (result = = "") {try {result = Mo[wmiprop Erty]. ToString (); Break } Catch {}}} return Resul T }//CPU ID getidentifier ("win32_processor", "UniqueId");//processor idgetidentifier ("Win32_Processor", "Processorid" );//processor namegetidentifier ("Win32_Processor", "Name")//manufacturergetidentifier ("Win32_Processor", " Manufacturer ");//bios Identifier private static string Getbiosid () {return getidentifIER ("Win32_BIOS", "Manufacturer") + Getidentifier ("Win32_BIOS", "smbiosbiosversion") + Getidentifier ("Win32_BIOS", "Identificationcode") + getidentifier ("Win32_BIOS", "serialnumber") + Getidentifier (" Win32_BIOS "," releasedate ") + getidentifier (" Win32_BIOS "," Version "); }//main physical hard drive ID private static string Getdiskid () {return Getidentifier (" Win32_DiskDrive "," Model ") + getidentifier (" Win32_DiskDrive "," Manufacturer ") + Getidentifier (" Win32 _diskdrive "," Signature ") + getidentifier (" Win32_DiskDrive "," totalheads "); }//motherboard ID private static string Getbaseid () {return Getidentifier ("Win32_baseboa Rd "," Model ") + getidentifier (" Win32_baseboard "," Manufacturer ") + Getidentifier (" Win32_baseboard ", "Name") + getidentifier ("Win32_baseboard", "serialnumber"); } Primary Video controller ID private static string Getvideoid () {return Getidentifier ("Win32_v Ideocontroller "," driverversion ") + getidentifier (" Win32_VideoController "," Name "); }//first enabled network card ID private static string Getmacid () {return Getidentifier ( "Win32_NetworkAdapterConfiguration", "MACAddress", "ipenabled"); }
The above is the C # Some of the methods to obtain hardware parameters, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!