Get CPU Serial No - CSharp Operating System

CSharp examples for Operating System:Cpu

Description

Get CPU Serial No

Demo Code

// All Rights Reserved , Copyright (C) 2012 , Hairihan TECH, Ltd. 
using System.Net.NetworkInformation;
using System.Net;
using System.Management;
using System.Collections.Generic;

public class Main{
        public static string GetCPUSerialNo()
        {/*from w  w  w.j a  v  a2 s  .  co m*/
            string cpuSerialNo = string.Empty;
            ManagementClass managementClass = new ManagementClass("Win32_Processor");
            ManagementObjectCollection managementObjectCollection = managementClass.GetInstances();
            foreach (ManagementObject managementObject in managementObjectCollection)
            {
                cpuSerialNo = managementObject.Properties["ProcessorId"].Value.ToString();
                break;
            }
            return cpuSerialNo;
        }
}

Related Tutorials