public string GetComputerId() { Listlist = new List(); ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive"); foreach (ManagementObject wmi_HD in searcher.Get()) { try { HardDrive hd = new HardDrive(); hd.Model = wmi_HD["Model"].ToString(); hd.Type = wmi_HD["InterfaceType"].ToString(); if (hd.Type.ToLowerInvariant().Contains("usb")) { continue; } if (wmi_HD["SerialNumber"] != null) { hd.SerialNo = wmi_HD["SerialNumber"].ToString(); } list.Add(hd); } catch { } } searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia"); foreach (ManagementObject wmi_HD in searcher.Get()) { try { HardDrive hd = new HardDrive(); // get the hardware serial no. if (wmi_HD["SerialNumber"] == null || string.IsNullOrEmpty(wmi_HD["SerialNumber"].ToString())) { continue; } else hd.SerialNo = wmi_HD["SerialNumber"].ToString(); } catch { } } ManagementClass mc = new ManagementClass("Win32_BaseBoard"); ManagementObjectCollection moc = mc.GetInstances();