当前位置:编程学习 > C#/ASP.NET >>

C#读取计算机CPU,HDD信息

public string getCpuInfo() //读取CPU信息
        {
            ManagementClass mobj = new ManagementClass("Win32_Processor");
            ManagementObjectCollection moc = mobj.GetInstances();
            foreach (ManagementObject mo in moc)
            {
                return mo.Properties["ProcessorId"].Value.ToString();
            }
            return "";
        }
        public string getHddInfo() //读取硬盘信息
        {
            ManagementClass mobj = new ManagementClass("Win32_PhysicalMedia");
            ManagementObjectCollection moc = mobj.GetInstances();
            foreach (ManagementObject mo in moc)
            {
                return mo.Properties["SerialNumber"].Value.ToString();
            }
            return "";
        }

 

 

摘自 爱智旮旯

补充:软件开发 , C# ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,