Thursday, February 25, 2010

Retrieving Serial Number of BIOS

Nowadays, i have been working on Windows Desktop Application. In this project, i need to match application's serial number and BIOS' serial number to prevent illegal usage. To retrieve BIOS number of computer i  used WMI Classes with .NET Framework namespace called System.Management. If you need to retrieve Serial Number of BIOS you can use following code snippet :
   1:  ManagementObjectSearcher wmiQuery = new ManagementObjectSearcher("SELECT * FROM Win32_BIOS");
   2:  ManagementObjectCollection wmiColl = wmiQuery.Get();
   3:   
   4:  foreach (ManagementObject item in wmiColl)
   5:  {
   6:     Console.WriteLine(item.GetPropertyValue("SerialNumber"));
   7:  }
If you want to check other properties' name of Win32_BIOS, click to see link written below :
http://msdn.microsoft.com/en-us/library/aa394077(VS.85).aspx

No comments: