-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProcessor.cs
47 lines (38 loc) · 1.29 KB
/
Processor.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
using System.Management;
namespace powerLabel
{
public class Processor
{
public int id { get; set; }
public string name { get; set; }
public uint cores { get; set; }
public uint threads { get; set; }
public static Processor GetProcessor(ComputerSystem system)
{
Processor processor = new Processor();
ManagementObjectCollection returned = PSInterface.RunObjectQuery("SELECT * FROM Win32_Processor");
ManagementObject item = null;
foreach (ManagementObject obj in returned)
{
item = obj;
break;
}
system.processorAmount = (returned.Count > 1) ? 2 : 1;
processor.name = (string)item["Name"];
processor.cores = (uint)item["NumberOfCores"];
processor.threads = (uint)item["NumberOfLogicalProcessors"];
return processor;
}
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType()) return false;
Processor processor = (Processor)obj;
if (this.name.Trim() == processor.name.Trim()
)
{
return true;
}
return false;
}
}
}