Thursday, August 29, 2013

Get the Motherboard Details of Your System in Windows Form

Inline image 1

Introduction

This article explains how to get the details of the Motherboard of your system. Here I will get the information from the Win32_MotherboardDevice class.

What Win32_MotherboardDevice is

The Win32_MotherboardDevice WMI class a represents a device that contains the central components of the Windows computer system. 
 

Design
 
Create a new Windows Forms Application Project.

Add one button control to the form.

...
...

private void button1_Click(object sender, EventArgs e)
        {
            SelectQuery Sq = new SelectQuery("Win32_MotherboardDevice");
            ManagementObjectSearcher objOSDetails = new ManagementObjectSearcher(Sq);
            ManagementObjectCollection osDetailsCollection = objOSDetails.Get();
            StringBuilder sb = new StringBuilder();
            foreach (ManagementObject mo in osDetailsCollection)
            {
                sb.AppendLine(string.Format("Caption: {0}", (string)mo["Caption"]));
                sb.AppendLine(string.Format("Availability: {0}", mo["Availability"].ToString()));
                sb.AppendLine(string.Format("InstallDate: {0}", Convert.ToDateTime(mo["InstallDate"]).ToString()));
                sb.AppendLine(string.Format("CreationClassName : {0}", (string)mo["CreationClassName"]));
                sb.AppendLine(string.Format("Description: {0}", (string)mo["Description"]));
                sb.AppendLine(string.Format("DeviceID : {0}", (string)mo["DeviceID"]));
                sb.AppendLine(string.Format("ErrorCleared: {0}", (string)mo["ErrorCleared"]));
                sb.AppendLine(string.Format("ErrorDescription : {0}", (string)mo["ErrorDescription"]));
                sb.AppendLine(string.Format("PrimaryBusType : {0}", (string)mo["PrimaryBusType"]));
                sb.AppendLine(string.Format("RevisionNumber : {0}", (string)mo["RevisionNumber"]));
                sb.AppendLine(string.Format("LastErrorCode : {0}", (string)mo["LastErrorCode"]));
                sb.AppendLine(string.Format("Name : {0}", (string)mo["Name"]));
                sb.AppendLine(string.Format("SecondaryBusType : {0}", (string)mo["SecondaryBusType"]));
                sb.AppendLine(string.Format("PNPDeviceID: {0}", (string)mo["PNPDeviceID"]));
                sb.AppendLine(string.Format("PowerManagementSupported : {0}", mo["PowerManagementSupported"]).ToString());
                sb.AppendLine(string.Format("Status : {0}", (string)mo["Status"]));
                sb.AppendLine(string.Format("SystemCreationClassName : {0}", (string)mo["SystemCreationClassName"]));
                sb.AppendLine(string.Format("SystemName: {0}", (string)mo["SystemName"]));
            }
            MessageBox.Show(sb.ToString());
        }

Read more: C# Corner
QR: Inline image 2