• 获取主板、硬盘、CPU、网卡编号


    using System; 
    using System.Collections.Generic; 
    using System.Text; 
    using System.Management; 

    namespace ConsoleApplication1 

        class Program 
        { 
            static void Main(string[] args) 
            { 
                ManagementClass processorCls = new ManagementClass("Win32_Processor"); 
                ManagementClass HarddiscID = new ManagementClass("Win32_DiskDrive"); 
                ManagementClass NetWorkCard = new ManagementClass("Win32_NetworkAdapterConfiguration"); 

                // CPU处理器的信息 
                foreach(ManagementObject processorObj in processorCls.GetInstances())
                { 
                    Console.WriteLine("Processor Id:"+processorObj["ProcessorId"]); 
                    Console.WriteLine("Processor Name:" + processorObj["Name"]); 
                    Console.WriteLine("Current Clock Speed:" + processorObj["CurrentClockSpeed"]); 
                } 
                // 硬盘的信息 
                foreach (ManagementObject LogicalDiskObj in HarddiscID.GetInstances()) 
                { 
                    Console.WriteLine("LogicalDisk Id:" + LogicalDiskObj["Model"]); 
                    Console.WriteLine("LogicalDisk Name:" + LogicalDiskObj["Name"]); 
                    //Console.WriteLine("Current Clock Speed:" + LogicalDiskObj["CurrentClockSpeed"]); 
                } 
                //网卡的序列号 
                foreach (ManagementObject NetWorkCardObj in NetWorkCard.GetInstances()) 
                { 
                    if ((bool)NetWorkCardObj["IPEnabled"] == true) 
                      Console.WriteLine("NetWorkCard Id:" + NetWorkCardObj["MacAddress"].ToString()); 
                    NetWorkCardObj.Dispose(); 
                    //Console.WriteLine("LogicalDisk Name:" + LogicalDiskObj["Name"]); 
                    //Console.WriteLine("Current Clock Speed:" + LogicalDiskObj["CurrentClockSpeed"]); 
                } 
                //主板的信息 
                string strbNumber = string.Empty; 
                ManagementObjectSearcher mos = new ManagementObjectSearcher("select * from Win32_baseboard"); 
                foreach (ManagementObject mo in mos.Get()) 
                { 
                    strbNumber = mo["SerialNumber"].ToString(); 
                    Console.WriteLine("baseboard ID: " + strbNumber); 
                    //Console.WriteLine("baseboard ID" + mo["SerialNumber"]); 
                    Console.WriteLine("主板制造商:" + mo["Manufacturer"]); 
                    Console.WriteLine("型号:" + mo["Product"]); 
                    break; 
                } 
            } 
        } 
    }
  • 相关阅读:
    WPF and Silverlight 学习笔记:键盘输入、鼠标输入、焦点处理
    [转]Visual Studio .NET "目标平台" 说明
    WPF 使用HwndHost嵌入Win32后,无法接受Mouse_Move\Mouse_Leave消息
    c#有多少种可能导致写文件失败?
    优化性能:文本【msdn】
    解决popup不随着window一起移动的问题
    异常处理的资料
    利用bat编译WPF项目
    属性值继承
    WPF消息机制
  • 原文地址:https://www.cnblogs.com/gyxdbk/p/1432017.html
Copyright © 2020-2023  润新知