1

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

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

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

4

1 回答 1

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();
        }
    }
}

希望这会有所帮助

于 2013-04-22T18:05:59.070 回答