維美技術 http://blog.csdn.net/lesen
using System;
using System.Collections.Generic;
using System.Text;
using System.Management;
namespace CS
{
class Program
{
static void Main(string[] args)
{
PrintMotherBoardInfo();
Console.WriteLine(GetMotherBoardSerialNumber());
}
/// <summary>
/// 列印主機板資訊
/// </summary>
private static void PrintMotherBoardInfo()
{
ManagementClass mc = new ManagementClass("WIN32_BaseBoard");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
foreach (PropertyData pd in mo.Properties)
{
Console.WriteLine(string.Format("{0}{1}{2}",pd.Name,"/t", pd.Value));
}
}
}
//獲取主機板序號
private static string GetMotherBoardSerialNumber()
{
ManagementClass mc = new ManagementClass("WIN32_BaseBoard");
ManagementObjectCollection moc = mc.GetInstances();
string SerialNumber = "";
foreach (ManagementObject mo in moc)
{
SerialNumber= mo["SerialNumber"].ToString();
break;
}
return SerialNumber;
}
}
}