【问题标题】:Windows API to get Motherboard Model and NameWindows API 获取主板型号和名称
【发布时间】:2012-11-30 05:50:50
【问题描述】:

我正在windows上编写一个应用程序来获取主板的信息。我要收集的信息是

  • 主板制造商(例如戴尔或技嘉)
  • 主板型号(例如 T3600 或 GA-Z77)

谁能告诉我应该使用哪个 API 来获取这些信息?

【问题讨论】:

标签: motherboard


【解决方案1】:

这是第一个答案,感谢您对本网站的感谢 首先将 System.Management 引用添加到您的项目 试试这个

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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            // First we create the ManagementObjectSearcher that
            // will hold the query used.
            // The class Win32_BaseBoard (you can say table)
            // contains the Motherboard information.
            // We are querying about the properties (columns)
            // Product and SerialNumber.
            // You can replace these properties by
            // an asterisk (*) to get all properties (columns).
            ManagementObjectSearcher searcher =
                new ManagementObjectSearcher("SELECT Product, SerialNumber FROM Win32_BaseBoard");

            // Executing the query...
            // Because the machine has a single Motherborad,
            // then a single object (row) returned.
            ManagementObjectCollection information = searcher.Get();
            foreach (ManagementObject obj in information)
            {
                // Retrieving the properties (columns)
                // Writing column name then its value
                foreach (PropertyData data in obj.Properties)
                    Console.WriteLine("{0} = {1}", data.Name, data.Value);
                Console.WriteLine();
            }

            // For typical use of disposable objects
            // enclose it in a using statement instead.
            searcher.Dispose();
            Console.Read();
        }
    }
}

希望对你有所帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-16
    • 1970-01-01
    • 2011-08-08
    • 2019-01-15
    • 2016-02-14
    • 2013-08-13
    • 1970-01-01
    • 2010-11-06
    相关资源
    最近更新 更多