检测bios信息及源码

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


namespace SystemInfo
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {

                Console.ForegroundColor = ConsoleColor.Red;

                Console.WriteLine("正在检测请稍候");

                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("===================================");
                Console.WriteLine("操作系统信息");
                Console.WriteLine("===================================");

                ManagementObjectSearcher searcher =
                    new ManagementObjectSearcher("root\\CIMV2",
                    "SELECT * FROM Win32_OperatingSystem");

                foreach (ManagementObject queryObj in searcher.Get())
                {
                    Console.WriteLine("-----------------------------------");
                    Console.WriteLine("系统名称: {0}", queryObj["Caption"]);
                    Console.WriteLine("版本: {0}", queryObj["CSDVersion"]);
                    Console.WriteLine("计算机名称: {0}", queryObj["CSName"]);
                    Console.WriteLine("单位: {0}", queryObj["Organization"]);
                    Console.WriteLine("注册用户: {0}", queryObj["RegisteredUser"]);
                    Console.WriteLine("序列号: {0}", queryObj["SerialNumber"]);
                    Console.WriteLine("系统所在分区: {0}", queryObj["SystemDrive"]);
                    Console.WriteLine("系统目录: {0}", queryObj["WindowsDirectory"]);
                    Console.WriteLine("系统System32所在目录: {0}", queryObj["SystemDirectory"]);
                    Console.WriteLine("可用内存: {0}", queryObj["TotalVisibleMemorySize"]);
                    Console.WriteLine("版本号: {0}", queryObj["Version"]);
                    Console.WriteLine("-----------------------------------");

                }

                Console.WriteLine("===================================");
                Console.WriteLine("BIOS信息");
                Console.WriteLine("===================================");
                searcher =
                    new ManagementObjectSearcher("root\\CIMV2",
                    "SELECT * FROM Win32_SystemBIOS");
                foreach (ManagementObject queryObj in searcher.Get())
                {
                    Console.WriteLine("-----------------------------------");
                    Console.WriteLine("汇总信息: {0}", queryObj["PartComponent"]);
                    Console.WriteLine("-----------------------------------");
                }

                Console.WriteLine("===================================");
                Console.WriteLine("计算机系统信息");
                Console.WriteLine("===================================");
                searcher =
                    new ManagementObjectSearcher("root\\CIMV2",
                    "SELECT * FROM Win32_ComputerSystem");

                foreach (ManagementObject queryObj in searcher.Get())
                {
                    Console.WriteLine("-----------------------------------");
                    Console.WriteLine("计算机全称: {0}", queryObj["Name"]);
                    Console.WriteLine("处理器数量: {0}", queryObj["NumberOfProcessors"]);
                    Console.WriteLine("描述: {0}", queryObj["Description"]);
                    Console.WriteLine("域: {0}", queryObj["Domain"]);
                    Console.WriteLine("系统类型: {0}", queryObj["SystemType"]);
                    Console.WriteLine("实际内存: {0}", queryObj["TotalPhysicalMemory"]);
                    Console.WriteLine("用户名: {0}", queryObj["UserName"]);
                    Console.WriteLine("-----------------------------------");
                }

                searcher =
                   new ManagementObjectSearcher("root\\CIMV2",
                   "SELECT * FROM Win32_Processor");
                Console.WriteLine("===================================");
                Console.WriteLine("CPU信息");
                Console.WriteLine("===================================");
                foreach (ManagementObject queryObj in searcher.Get())
                {
                    Console.WriteLine("-----------------------------------");
                    Console.WriteLine("编号: {0}", queryObj["DeviceID"]);
                    Console.WriteLine("CPU序列号: {0}", queryObj["ProcessorId"]);
                    Console.WriteLine("Cpu状态: {0}", queryObj["CpuStatus"]);
                    Console.WriteLine("类别: {0}", queryObj["Caption"]);
                    Console.WriteLine("名称: {0}", queryObj["Name"]);
                    Console.WriteLine("描述: {0}", queryObj["Description"]);
                    Console.WriteLine("寻址: {0}", queryObj["AddressWidth"]);
                    Console.WriteLine("数据带宽: {0}", queryObj["DataWidth"]);
                    Console.WriteLine("时钟频率: {0}", queryObj["CurrentClockSpeed"]);
                    Console.WriteLine("最高时钟频率: {0}", queryObj["MaxClockSpeed"]);
                    Console.WriteLine("版本: {0}", queryObj["Version"]);
                    Console.WriteLine("电压: {0}", queryObj["CurrentVoltage"]);
                    Console.WriteLine("二级缓容量: {0}", queryObj["L2CacheSize"]);
                    Console.WriteLine("二级缓频率: {0}", queryObj["L2CacheSpeed"]);
                    Console.WriteLine("-----------------------------------");
                }

                searcher =
                   new ManagementObjectSearcher("root\\CIMV2",
                   "SELECT * FROM Win32_LogicalDisk");
                Console.WriteLine();
                Console.WriteLine("===================================");
                Console.WriteLine("硬盘信息");
                Console.WriteLine("===================================");
                foreach (ManagementObject queryObj in searcher.Get())
                {
                    Console.WriteLine("-----------------------------------");

                    Console.WriteLine("卷标: {0}", queryObj["VolumeName"]);
                    Console.WriteLine("序列号: {0}", queryObj["VolumeSerialNumber"]);
                    Console.WriteLine("驱动器号: {0}", queryObj["Name"]);
                    Console.WriteLine("分区大小: {0}", queryObj["Size"]);
                    Console.WriteLine("可用空间: {0}", queryObj["FreeSpace"]);
                    Console.WriteLine("文件系统: {0}", queryObj["FileSystem"]);
                    Console.WriteLine("描述: {0}", queryObj["Description"]);
                    Console.WriteLine("-----------------------------------");

                }

                Console.WriteLine();
                Console.WriteLine("===================================");
                Console.WriteLine("网卡信息");
                Console.WriteLine("===================================");
                searcher =
                    new ManagementObjectSearcher("root\\CIMV2",
                    "SELECT * FROM Win32_NetworkAdapter WHERE MACAddress = '00:0D:61:70:6B:90'");

                foreach (ManagementObject queryObj in searcher.Get())
                {
                    Console.WriteLine("-----------------------------------");
                    Console.WriteLine("名称: {0}", queryObj["Name"]);
                    Console.WriteLine("说明: {0}", queryObj["Caption"]);
                    Console.WriteLine("描述: {0}", queryObj["Description"]);
                    Console.WriteLine("MAC地址: {0}", queryObj["MACAddress"]);
                    Console.WriteLine("GUID: {0}", queryObj["GUID"]);
                    Console.WriteLine("适配器类型: {0}", queryObj["AdapterType"]);
                    Console.WriteLine("-----------------------------------");
                }

                Console.WriteLine();
                Console.WriteLine("===================================");
                Console.WriteLine("网络信息");
                Console.WriteLine("===================================");
                searcher = new ManagementObjectSearcher("root\\CIMV2",
                    "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'");


                // Every record in this collection is a network interface
                foreach (ManagementObject mo in searcher.Get())
                {
                    Console.WriteLine("-----------------------------------");
                    Console.WriteLine("主机名称:{0} ", mo["DNSHostName"]);
                    Console.WriteLine("网卡描述:{0}= ", mo["Description"]);

                    // IPAddresses, probably have more than one value
                    string[] addresses = (string[])mo["IPAddress"];
                    foreach (string ipaddress in addresses)
                    {
                        Console.WriteLine("IP地址:{0} ", ipaddress);
                    }

                    // DefaultIPGateways, probably have more than one value
                    string[] defaultgateways = (string[])mo["DefaultIPGateway"];
                    foreach (string defaultipgateway in defaultgateways)
                    {
                        Console.WriteLine("您的默认网关是 :{0}", defaultipgateway);
                    }
                    Console.WriteLine("-----------------------------------");
                }

                Console.WriteLine();
                Console.WriteLine("您好,检测完毕");
                Console.ReadLine();
            }
            catch (ManagementException e)
            {
                Console.WriteLine("对不起,读取数据发生错误,原因: " + e.Message);
            }
        }
    }
}

你可能感兴趣的:(ios)