使用System.Management命名空間下的ManagementObjectSearcher類可以獲取主板編號信息。首先添加對System.Management類庫的引用。然後添加下述代碼,就可獲得主板的編號。主要程序代碼。
private void button1_Click(object sender, EventArgs e)
{
SelectQuery Query = new SelectQuery("SELECT * FROM Win32_BaseBoard");
ManagementObjectSearcher driveID = new ManagementObjectSearcher(Query);
ManagementObjectCollection.ManagementObjectEnumerator data = driveID.Get().GetEnumerator();
data.MoveNext();
ManagementBaseObject board = data.Current;
textBox1.Text = board.GetPropertyValue("SerialNumber").ToString();
}