C # get the MAC address \ serial number \ HDD Serial number of this machine

Source: Internet
Author: User
1///<summary> 2///display MAC address 3///</summary> 4///<returns></returns&
 Gt
 5 private String Getmac () 6 {7 String mac = "Local MAC address:";                 8 using (ManagementClass MC = new ManagementClass ("Win32_NetworkAdapterConfiguration")) 9 {10 Managementobjectcollection MOC = MC.
GetInstances (); One foreach (ManagementObject mo in MoC) {if ((bool) mo["ipenable D "]) {string[] Tmpmac = mo[" MacAddress "]. ToString ().
Split (': ');                             for (int i = 0; i < tmpmac.length i++) 17 {18
Mac + + Tmpmac[i]; } "return Mac +" \
r\n ";     ///<summary> 27///Get native CPU serial number 28    </summary>///<returns></returns> private String Getcpuid () 31 {
CPUID = "CPU serial number of this machine:"; By using (ManagementClass MC = new ManagementClass ("Win32_Processor")) Agementobjectcollection MOC = MC.
GetInstances (); (ManagementObject item in MOC) CPUID + = item["Proce Ssorid "]. ToString ().
Trim ();
CPUID + "\ r \ n"; ///<summary> 45///get local hard drive serial number///</summary>///&L T;returns></returns> private String Gethardid () {string hardid = "CPU serial number of this machine
:"; using (ManagementClass mc = new ManagementClass ("Win32_DiskDrive")) Agementobjectcollection MOC = MC.
GetInstances ();                54 foreach (ManagementObject item in MOC) Hardid + = item["Model"]. ToString ().
Trim ();
Hardid + "\ r \ n";  60

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.