How to get computer serial number using windows application c# on windows 10 OS
Hi,Please help me, i have a windows application that is working fine on machines with windows 7 operating system,but when I run/deploy the system on windows 10 machine it does not work.
This app is suppose to get a serial number of the machine the app is running on,as well as the person logged in on a computer.
Below is the code that i am using to get computer serial number,it is working well on windows 7,but not on windows 10.
void GetSerialNumber()
{
//Get machine serial number
SelectQuery Sq = new SelectQuery("Win32_BIOS");
ManagementObjectSearcher objOSDetails = new ManagementObjectSearcher(Sq);
ManagementObjectCollection osDetailsCollection = objOSDetails.Get();
foreach (ManagementObject mo in osDetailsCollection)
{
string[] BIOSVersion = (string[])mo["BIOSVersion"];
string s2 = null;
foreach (string version in BIOSVersion)
{
s2 += version;
}
lblserialno.Text = mo["SerialNumber"].ToString();
}
}