-
Notifications
You must be signed in to change notification settings - Fork 0
/
Motherboard.cs
54 lines (45 loc) · 1.66 KB
/
Motherboard.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System.Management;
namespace powerLabel
{
public class Motherboard
{
public int id { get; set; }
public string model { get; set; }
public string manufacturer { get; set; }
public string serialNumber { get; set; }
public static Motherboard GetMotherboard()
{
Motherboard motherboard = new Motherboard();
foreach (ManagementObject system in PSInterface.RunObjectQuery("SELECT * FROM Win32_ComputerSystem"))
{
motherboard.manufacturer = (string)system["Manufacturer"];
if (motherboard.manufacturer.Trim().Equals("Lenovo", System.StringComparison.InvariantCultureIgnoreCase))
{
motherboard.model = (string)system["SystemFamily"];
}
else
{
motherboard.model = (string)system["Model"];
}
}
foreach (ManagementObject bios in PSInterface.RunObjectQuery("SELECT * FROM Win32_Bios"))
{
motherboard.serialNumber = (string)bios["SerialNumber"];
}
return motherboard;
}
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType()) return false;
Motherboard mobo = (Motherboard)obj;
if (this.model.Trim() == mobo.model.Trim() &&
this.manufacturer.Trim() == mobo.manufacturer.Trim() &&
this.serialNumber.Trim() == mobo.serialNumber.Trim()
)
{
return true;
}
return false;
}
}
}