-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
37 lines (33 loc) · 1.05 KB
/
Form1.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
using System.Management;
namespace PW1SPP
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void GetButton_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
try
{
Double CPUtprt = 0;
ManagementObjectSearcher MOS = new("root\\WMI",
"SELECT * FROM MSAcpi_ThermalZoneTemperature");
foreach (ManagementObject Mo in MOS.Get().Cast<ManagementObject>())
{
CPUtprt = Convert.ToDouble(Convert.ToDouble(Mo.GetPropertyValue("CurrentTemperature".ToString())) - 2732) / 10.0;
listBox1.Items.Add(" CPU: " + CPUtprt.ToString() + " ° C");
}
}
catch (ManagementException ex)
{
MessageBox.Show("Îøèáêà ïîëó÷åíèÿ äàííûõ " + ex.Message);
}
}
}
}