マザーボードの情報を取得するために Windows でアプリケーションを作成しています。私が集めたい情報は、
- マザーボードの製造元 (Dell または Gigabyte など)
- マザーボードのモデル (例: T3600 または GA-Z77)
この情報を取得するためにどの API を使用すればよいか教えてください。
マザーボードの情報を取得するために Windows でアプリケーションを作成しています。私が集めたい情報は、
この情報を取得するためにどの API を使用すればよいか教えてください。
これは、このサイトに感謝するための最初の回答です。プロジェクトに System.Management refrence を追加して、これを試してください。
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();
}
}
}
それが役立つことを願っています