Get the BIOS Details of Your System in ASP.Net

Introduction

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

What Win32_BIOS  is

The Win32_Desktop WMI class represents the attributes of the computer system's Basic Input/Output Services (BIOS) that are installed on a computer.

Design

Create a new ASP.Net Empty website.

Add one page to that website.

Write the following source code:


<
head runat="server">
    <title></title>
    <style type="text/css">
        html
        {
            font-size: 1.5em;
            font-family: Calibri;
            color: Red;
        }
    </style
>

</
head>
<
body>
    <form id="form1" runat="server">
    <div>
    </div>
    </form
>

</
body>
</
html>

Next add a reference of "System.Management".

To add the reference use the following procedure.

Go to Solution Explorer, select the project and right-click on that and choose "Add Reference" from the menu.

1.jpg

A window will open; in that choose the ".Net" tab.

2.jpg

It will show a list. In that list, choose "System.Management" and click the "OK" Button.

3.jpg

Now go to code view and write the following code:

using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Management;
public
partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SelectQuery Sq = new SelectQuery("Win32_BIOS");
        ManagementObjectSearcher objOSDetails = new ManagementObjectSearcher(Sq);
        ManagementObjectCollection osDetailsCollection = objOSDetails.Get();
        foreach (ManagementObject mo in osDetailsCollection)
        {

Response.Write("Name : " + mo["Name"].ToString() + "<br/>");
            string[] BIOSVersion = (string[])mo["BIOSVersion"];
            string s2 = null;
            foreach (string version in BIOSVersion)
            {
                s2 += version;
            }
            Response.Write("BIOSVersion : " + s2 + "<br/>");
            Response.Write("Caption : " + mo["Caption"].ToString() + "<br/>");
            Response.Write("Description : " + mo["Description"].ToString() + "<br/>");
            Response.Write("InstallableLanguages : " + Convert.ToUInt16(mo["InstallableLanguages"]).ToString() + "<br/>");   
            Response.Write("InstallDate : " + Convert.ToDateTime(mo["InstallDate"]).ToString() + "<br/>");
            Response.Write("Manufacturer : " + mo["Manufacturer"].ToString() + "<br/>");
            Response.Write("PrimaryBIOS : " + mo["PrimaryBIOS"].ToString() + "<br/>");
            Response.Write("ReleaseDate : " + mo["ReleaseDate"].ToString() + "<br/>");
            Response.Write("SerialNumber : " + mo["SerialNumber"].ToString() + "<br/>");
            Response.Write("SMBIOSBIOSVersion : " + mo["SMBIOSBIOSVersion"].ToString() + "<br/>");
            Response.Write("SMBIOSMajorVersion : " + mo["SMBIOSMajorVersion"].ToString() + "<br/>");
            Response.Write("SMBIOSMinorVersion : " + mo["SMBIOSMinorVersion"].ToString() + "<br/>");
            Response.Write("SMBIOSPresent : " + mo["SMBIOSPresent"].ToString() + "<br/>");
            Response.Write("SoftwareElementID : " + mo["SoftwareElementID"].ToString() + "<br/>");
            Response.Write("SoftwareElementState : " + mo["SoftwareElementState"].ToString() + "<br/>");
            Response.Write("Status : " + mo["Status"].ToString() + "<br/>");
            Response.Write("TargetOperatingSystem : " + mo["TargetOperatingSystem"].ToString() + "<br/>");
            Response.Write("Version: " + mo["Version"].ToString() + "<br/>");
    }
}


In the code above I get the information from Win32_BIOS and display that in the page.


SelectQuery

It represents a WQL (WMI Query Language) SELECT data query.

ManagementObjectSearcher

It retrieves a collection of management objects based on a specified query.

This class is one of the more commonly used entry points to retrieving management information.

ManagementObjectCollection

It represents various collections of management objects retrieved using WMI.

Now build your application, it will show the details of your BIOS details of your system in the page.

4.jpeg

Up Next
    Ebook Download
    View all
    Learn
    View all