WMI之类的我已经试过了,用不成。
但有使用C#,调用openhardwaremonitorlib.dll库文件 成功案例。
现有需求要在VB 6 编程环境下,使用openhardwaremonitorlib.dll库文件 ,
解决实时读取CPU和硬盘温度的需求。
VB 6 编程环境,找不到合适实时读取CPU和硬盘温度的案例,如有专家能解决这个问题,并提供源代码,十分感谢!
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
threenewbee 2020-08-03 18:18关注wmi其实也是可以的,只是一些主板硬件不支持,另外你既然提到openhardwaremonitorlib.dll,其实你可以用regasm可以把它暴露成com接口,然后vb6以activex dll的方式饮用后可以调用。
帮你搞了一个
看下面的效果:
Private Sub Command1_Click() Dim obj As Object Set obj = CreateObject("Q1093036Lib.Class1") Dim s As String s = obj.GetTemperature() MsgBox s End Subusing System; using System.Collections.Generic; using System.Linq; using System.Text; using OpenHardwareMonitor; using OpenHardwareMonitor.Collections; using OpenHardwareMonitor.Hardware; using System.Runtime.InteropServices; namespace Q1093036Lib { [ComVisible(true)] public class Class1 { [ComVisible(true)] public string GetTemperature() { string s = ""; Computer computer = new Computer(); computer.MainboardEnabled = true; computer.CPUEnabled = true; computer.HDDEnabled = true; computer.RAMEnabled = true; computer.GPUEnabled = true; computer.FanControllerEnabled = true; computer.Open(); foreach (var hardware in computer.Hardware) { hardware.Update(); foreach (var sensor in hardware.Sensors) { s += sensor.Name + ":" + sensor.Value + "\r\n"; } } return s; } } }留下email,采纳回答,把完整的项目代码给你
其他人如果也需要,可以从 https://download.csdn.net/download/caozhy/12683629 下载
本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报解决 3无用