Skip to content

Commit 88e91a7

Browse files
switch LibreHardwareMonitor Lib
1 parent 35f556d commit 88e91a7

File tree

6 files changed

+137
-14
lines changed

6 files changed

+137
-14
lines changed

客户端/HardwareMonitor.csproj

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,25 @@
88
<OutputType>Exe</OutputType>
99
<RootNamespace>HardwareMonitor</RootNamespace>
1010
<AssemblyName>HardwareMonitor</AssemblyName>
11-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
11+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
1212
<FileAlignment>512</FileAlignment>
1313
<Deterministic>true</Deterministic>
14+
<TargetFrameworkProfile />
15+
<IsWebBootstrapper>false</IsWebBootstrapper>
16+
<PublishUrl>publish\</PublishUrl>
17+
<Install>true</Install>
18+
<InstallFrom>Disk</InstallFrom>
19+
<UpdateEnabled>false</UpdateEnabled>
20+
<UpdateMode>Foreground</UpdateMode>
21+
<UpdateInterval>7</UpdateInterval>
22+
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
23+
<UpdatePeriodically>false</UpdatePeriodically>
24+
<UpdateRequired>false</UpdateRequired>
25+
<MapFileExtensions>true</MapFileExtensions>
26+
<ApplicationRevision>0</ApplicationRevision>
27+
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
28+
<UseApplicationTrust>false</UseApplicationTrust>
29+
<BootstrapperEnabled>true</BootstrapperEnabled>
1430
</PropertyGroup>
1531
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1632
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -31,9 +47,18 @@
3147
<ErrorReport>prompt</ErrorReport>
3248
<WarningLevel>4</WarningLevel>
3349
</PropertyGroup>
50+
<PropertyGroup>
51+
<TargetZone>LocalIntranet</TargetZone>
52+
</PropertyGroup>
53+
<PropertyGroup>
54+
<GenerateManifests>true</GenerateManifests>
55+
</PropertyGroup>
56+
<PropertyGroup>
57+
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
58+
</PropertyGroup>
3459
<ItemGroup>
35-
<Reference Include="OpenHardwareMonitorLib">
36-
<HintPath>.\OpenHardwareMonitorLib.dll</HintPath>
60+
<Reference Include="LibreHardwareMonitorLib">
61+
<HintPath>.\LibreHardwareMonitorLib.dll</HintPath>
3762
</Reference>
3863
<Reference Include="System" />
3964
<Reference Include="System.Core" />
@@ -51,6 +76,14 @@
5176
</ItemGroup>
5277
<ItemGroup>
5378
<None Include="App.config" />
79+
<None Include="Properties\app.manifest" />
80+
</ItemGroup>
81+
<ItemGroup>
82+
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
83+
<Visible>False</Visible>
84+
<ProductName>.NET Framework 3.5 SP1</ProductName>
85+
<Install>false</Install>
86+
</BootstrapperPackage>
5487
</ItemGroup>
5588
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
5689
</Project>
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
4-
<StartArguments>192.168.3.162 4999 1.03 500 1 4</StartArguments>
4+
<StartArguments>192.168.3.162 4999 1.03 800 1 4</StartArguments>
5+
</PropertyGroup>
6+
<PropertyGroup>
7+
<PublishUrlHistory>publish\</PublishUrlHistory>
8+
<InstallUrlHistory />
9+
<SupportUrlHistory />
10+
<UpdateUrlHistory />
11+
<BootstrapperUrlHistory />
12+
<ErrorReportUrlHistory />
13+
<FallbackCulture>zh-CN</FallbackCulture>
14+
<VerifyUploadedFiles>false</VerifyUploadedFiles>
15+
</PropertyGroup>
16+
<PropertyGroup>
17+
<EnableSecurityDebugging>false</EnableSecurityDebugging>
518
</PropertyGroup>
619
</Project>
696 KB
Binary file not shown.
-305 KB
Binary file not shown.

客户端/Program.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
using System.Net.Sockets;
66
using System.Text;
77
using System.Net;
8-
using OpenHardwareMonitor.Hardware;
98
using System.Collections.Generic;
109
using System.IO.Ports;
1110
using System.Collections;
11+
using LibreHardwareMonitor.Hardware;
1212

1313
namespace ConsoleApp1
1414
{
@@ -100,33 +100,37 @@ static void SetEsp32()
100100
{
101101
hardware.Update();
102102

103-
if (hardware.HardwareType == HardwareType.CPU)
103+
if (hardware.HardwareType == HardwareType.Cpu)
104104
{
105105
foreach (var sensor in hardware.Sensors)
106106
{
107107
if (sensor.SensorType == SensorType.Load)
108108
{
109109
if (sensor != null && sensor.Value != null)
110110
{
111-
if (sensor.Index == 0) //总占用率
111+
if (sensor.Name.Contains("Total"))
112112
{
113+
//总占用率
113114
cpuLoad = (double)sensor.Value;
114115
}
115116
}
116117
}
118+
117119
if (sensor.SensorType == SensorType.Temperature)
118120
{
119121
if (sensor != null && sensor.Value != null)
120122
{
121-
if (sensor.Index == 0)
123+
//显示平均温度
124+
//不同CPU返回的Name不同
125+
if (sensor.Name.Contains("Average"))
122126
{
123127
cpuTemperature = (double)sensor.Value;
124128
}
125129
}
126130
}
127131
}
128132
}
129-
else if (hardware.HardwareType == HardwareType.RAM)
133+
else if (hardware.HardwareType == HardwareType.Memory)
130134
{
131135
foreach (var sensor in hardware.Sensors)
132136
{
@@ -139,7 +143,7 @@ static void SetEsp32()
139143
}
140144
}
141145
} //没有此显卡为空
142-
else if (hardware.HardwareType == HardwareType.GpuAti)
146+
else if (hardware.HardwareType == HardwareType.GpuAmd)
143147
{
144148
foreach (var sensor in hardware.Sensors)
145149
{
@@ -225,7 +229,7 @@ static void SetEsp32()
225229
"\nID_5 GPU 显存占用: " + gpuRamLoad.ToString() + " %\n"+
226230
"\nID_6 GPU 温度: " + gpuTemperature.ToString() + " C\n"+
227231
"\n配置的数据类型: [" + _sendType_1.ToString() + "] / ["+ _sendType_2.ToString() + "] \n"+
228-
"\n----------------OpenHardwareMonitor------------------\n";
232+
"\n----------------LibreHardwareMonitor------------------\n";
229233
Console.WriteLine(writeLine);
230234
Esp32Connected(sendStr2.ToString() + "," + sendStr1.ToString());
231235

@@ -264,9 +268,9 @@ static void Init()
264268
{
265269
//初始化OpenHardwareMonitorLib
266270
computer = new Computer();
267-
computer.CPUEnabled = true;
268-
computer.RAMEnabled = true;
269-
computer.GPUEnabled = true;
271+
computer.IsCpuEnabled = true;
272+
computer.IsMemoryEnabled = true;
273+
computer.IsGpuEnabled = true;
270274
computer.Open();
271275

272276
if (isWiredWireless)

客户端/Properties/app.manifest

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
3+
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
4+
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
5+
<security>
6+
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
7+
<!-- UAC 清单选项
8+
如果想要更改 Windows 用户帐户控制级别,请使用
9+
以下节点之一替换 requestedExecutionLevel 节点。
10+
11+
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
12+
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
13+
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
14+
15+
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
16+
如果你的应用程序需要此虚拟化来实现向后兼容性,则移除此
17+
元素。
18+
-->
19+
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
20+
</requestedPrivileges>
21+
<applicationRequestMinimum>
22+
<defaultAssemblyRequest permissionSetReference="Custom" />
23+
<PermissionSet class="System.Security.PermissionSet" version="1" ID="Custom" SameSite="site" Unrestricted="true" />
24+
</applicationRequestMinimum>
25+
</security>
26+
</trustInfo>
27+
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
28+
<application>
29+
<!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
30+
Windows 版本的列表。取消评论适当的元素,
31+
Windows 将自动选择最兼容的环境。 -->
32+
<!-- Windows Vista -->
33+
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
34+
<!-- Windows 7 -->
35+
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
36+
<!-- Windows 8 -->
37+
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
38+
<!-- Windows 8.1 -->
39+
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
40+
<!-- Windows 10 -->
41+
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
42+
</application>
43+
</compatibility>
44+
<!-- 指示该应用程序可感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
45+
自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
46+
选择加入。选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应
47+
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。
48+
49+
将应用程序设为感知长路径。请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
50+
<!--
51+
<application xmlns="urn:schemas-microsoft-com:asm.v3">
52+
<windowsSettings>
53+
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
54+
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
55+
</windowsSettings>
56+
</application>
57+
-->
58+
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
59+
<!--
60+
<dependency>
61+
<dependentAssembly>
62+
<assemblyIdentity
63+
type="win32"
64+
name="Microsoft.Windows.Common-Controls"
65+
version="6.0.0.0"
66+
processorArchitecture="*"
67+
publicKeyToken="6595b64144ccf1df"
68+
language="*"
69+
/>
70+
</dependentAssembly>
71+
</dependency>
72+
-->
73+
</assembly>

0 commit comments

Comments
 (0)