082008
 
 
       public String GetCpuInfo()
        {
            //得到cpu信息
            string CPUInfo = "";
            ManagementClass mc = new ManagementClass("Win32_Processor");
            ManagementObjectCollection moc = mc.GetInstances();
            foreach (ManagementObject mo in moc)
            {
                CPUInfo = mo.Properties["ProcessorId"].Value.ToString();

            }
            return CPUInfo;
        }

 

        public string GetHDInfo()
        {
            //获取硬盘信息
            string HDInfo = "";
            ManagementClass mc = new ManagementClass("Win32_DiskDrive");
            ManagementObjectCollection moc = mc.GetInstances();
            foreach (ManagementObject mo in moc)
            {
                HDInfo = (string)mo.Properties["Model"].Value;
            }
            return HDInfo;
        }
        public static void GetMacAddress()

        {
            //获取网卡硬件地址

            string MacAddress = "";
            ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
            ManagementObjectCollection moc = mc.GetInstances();
            foreach (ManagementObject mo in moc)
            {
                if ((bool)mo["IPEnabled"] == true)
                    MacAddress = mo["MacAddress"].ToString();
                mo.Dispose();
            }
            return MacAddress;
        }

  One Response to “.Net 获取CPU信息,硬盘信息,网卡Mac信息”

  1. Den boken ska jag läsa. Tack för en sÃ¥ braaa blogg. Läser varje dag. Nu har jag inhandlat böcker av Charlaine Harris, mÃ¥ste läsa mÃ¥ste lÃ.¤….as.ser framemot att lära känna Sookie Stockhouse!!!!

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>