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 "";
        }

posted @ 2012-05-29 23:27  爱智旮旯  阅读(415)  评论(0编辑  收藏  举报