Skip to main content

Get the BIOS Serial Number with C#

Fisrt you have to import the following referenece in to your project.
System.Management

Sample Code
   1:  using System;
   2:  using System.Management;
   3:  using System.Windows.Forms;
   4:   
   5:  namespace DemoProjects
   6:  {
   7:      public partial class frmBIOSSerial : Form
   8:      {
   9:          public frmBIOSSerial()
  10:          {
  11:              InitializeComponent();
  12:          }
  13:   
  14:          private void btnGet_Click(object sender, EventArgs e)
  15:          {
  16:              string serialNumber = string.Empty;
  17:   
  18:              ManagementObjectSearcher MOS = new ManagementObjectSearcher(" Select * From Win32_BIOS ");
  19:              foreach (ManagementObject getserial in MOS.Get())
  20:              {
  21:                  serialNumber = getserial["SerialNumber"].ToString();
  22:              }
  23:   
  24:              lblSerialNumber.Text = serialNumber;
  25:          }
  26:      }
  27:  }

Comments

Tapan said…
Nice Job, Correct.