Reader Level:
ARTICLE

Get the BIOS Details of Your System in ASP.Net

On August 21, 2013 Articles | ASP.NET Programming
This article describes how to get the BIOS details of your System . Here I will get the information from the Win32_BIOS class.
  • 0
  • 0
  • 3103
Download Files:
 

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

Article Extensions
Contents added by Sanjeeb Lenka on Aug 21, 2013
Download File: BIOSdetails.zip
As it is in asp.net it will show the bios information of server if uploaded in server. if you run it in local machine it will show yours.
As i got a comment  from our editor it will be very useful for desktop application. so i am providing sample for desktop.

Step-1

Create a windows form application project.
In that Next add a reference of "System.Management".
To add the reference follow the above procedure.
Now put a button control on the form and on the button click event write the following code.

 private void button1_Click(object sender, EventArgs e)
{
SelectQuery Sq = new SelectQuery("Win32_BIOS");
ManagementObjectSearcher objOSDetails = new ManagementObjectSearcher(Sq);
ManagementObjectCollection osDetailsCollection = objOSDetails.Get();
StringBuilder sb = new StringBuilder();
foreach (ManagementObject mo in osDetailsCollection)
{
string[] BIOSVersions = (string[])mo["BIOSVersion"];
foreach (string version in BIOSVersions)
{
sb.AppendLine(string.Format("BIOSVersion: {0}", version));
}
sb.AppendLine(string.Format("BuildNumber: {0}", (string)mo["BuildNumber"]));
sb.AppendLine(string.Format("Caption: {0}", (string)mo["Caption"]));
sb.AppendLine(string.Format("CodeSet: {0}", (string)mo["CodeSet"]));
sb.AppendLine(string.Format("CurrentLanguage: {0}", (string)mo["CurrentLanguage"]));
sb.AppendLine(string.Format("Description: {0}", (string)mo["Description"]));
sb.AppendLine(string.Format("IdentificationCode: {0}", (string)mo["IdentificationCode"]));
sb.AppendLine(string.Format("InstallableLanguages: {0}", Convert.ToUInt16(mo["InstallableLanguages"]).ToString()));
sb.AppendLine(string.Format("InstallDate: {0}", Convert.ToDateTime(mo["InstallDate"]).ToString()));
sb.AppendLine(string.Format("LanguageEdition: {0}", (string)mo["LanguageEdition"]));
sb.AppendLine(string.Format("Manufacturer : {0}", (string)mo["Manufacturer"]));
}
MessageBox.Show(sb.ToString());
}

now run the form and click on button it will show all the bios details in Message box.


Thank you

Sanjeeb Lenka

I am currently working as a Software Engineer and have an experience  in C#.Net, Asp.net and Sql server . My work experience includes Development of Enterprise Applications using C#.Net, Asp.Ne...

  • 40rank
  • 305K readers
  • 1times
COMMENT USING

Trending up