C # Some ways to get hardware parameters

Source: Internet
Author: User
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)!

  • 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.