资源简介
C#读取电脑CPU温度winform测试程序,引用OpenHardwareMonitorLib.dll库,该dll库在debug夹下,listBox打印温度数据并显示

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OpenHardwareMonitor.Hardware;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public class UpdateVisitor : IVisitor
{
public void VisitComputer(IComputer computer)
{
computer.Traverse(this);
}
public void VisitHardware(IHardware hardware)
{
hardware.Update();
foreach (IHardware subHardware in hardware.SubHardware)
subHardware.Accept(this);
}
public void VisitSensor(ISensor sensor) { }
public void VisitParameter(IParameter parameter) { }
}
static int getTemperature()
{
int ret = 0;
Computer myComputer = new Computer();
UpdateVisitor updateVisitor = new UpdateVisitor();
myComputer.Open();
myComputer.Accept(updateVisitor);
foreach (var hardwareItem in myComputer.Hardware)
{
if (hardwareItem.HardwareType == HardwareType.CPU)
{
foreach (var sensor in hardwareItem.Sensors)
{
if (sensor.SensorType == SensorType.Temperature)
{
ret = Convert.ToInt32(sensor.Value);
}
}
}
}
return ret;
}
private void timer1_Tick(object sender EventArgs e)
{
int t = getTemperature();
label1.Text = “Now CPU Temp=“+t.ToString();
listBox1.Items.Add(“CPU Temp=“ + t.ToString());
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 274944 2012-05-27 02:36 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\OpenHardwareMonitorLib.dll
文件 10240 2018-09-03 11:31 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
文件 28160 2018-09-03 11:31 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb
文件 22472 2018-09-03 11:32 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe
文件 490 2018-04-12 07:35 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest
文件 274944 2012-05-27 02:36 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\bin\Release\OpenHardwareMonitorLib.dll
文件 9728 2018-09-03 11:34 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\bin\Release\WindowsFormsApplication1.exe
文件 26112 2018-09-03 11:34 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\bin\Release\WindowsFormsApplication1.pdb
文件 22472 2018-09-03 11:34 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\bin\Release\WindowsFormsApplication1.vshost.exe
文件 490 2018-04-12 07:35 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\bin\Release\WindowsFormsApplication1.vshost.exe.manifest
文件 2040 2018-09-03 11:31 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs
文件 2930 2018-09-03 11:31 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs
文件 6011 2018-09-03 11:31 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\Form1.resx
文件 1451 2018-09-03 11:16 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 7250 2018-09-03 11:06 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 274944 2012-05-27 02:36 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\OpenHardwareMonitorLib.dll
文件 1644 2018-09-03 11:32 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt
文件 975 2018-09-03 11:31 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.GenerateResource.Cache
文件 7121 2018-09-03 11:17 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csprojResolveAssemblyReference.cache
文件 10240 2018-09-03 11:31 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.exe
文件 180 2018-09-03 11:31 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Form1.resources
文件 28160 2018-09-03 11:31 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.pdb
文件 180 2018-09-03 11:17 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Properties.Resources.resources
文件 7254 2018-09-03 11:21 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\obj\Release\DesignTimeResolveAssemblyReferencesInput.cache
文件 274944 2012-05-27 02:36 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\obj\Release\OpenHardwareMonitorLib.dll
文件 1455 2018-09-03 11:34 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\obj\Release\WindowsFormsApplication1.csproj.FileListAbsolute.txt
文件 975 2018-09-03 11:34 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\obj\Release\WindowsFormsApplication1.csproj.GenerateResource.Cache
文件 9728 2018-09-03 11:34 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\obj\Release\WindowsFormsApplication1.exe
文件 180 2018-09-03 11:34 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\obj\Release\WindowsFormsApplication1.Form1.resources
文件 26112 2018-09-03 11:34 我的读取CPU温度测试1\WindowsFormsApplication1\WindowsFormsApplication1\obj\Release\WindowsFormsApplication1.pdb
............此处省略26个文件信息
- 上一篇:winform 自定义日期控件
- 下一篇:小程序获取openid(亲测通过)
相关资源
- C# IP地址输入控件
- C#在一个窗口刷新更改另一个窗口控件
- C# TIP文件生成和拆解
- C#解析HL7消息的库135797
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
评论
共有 条评论