WMI之类的我已经试过了,用不成。
但有使用C#,调用openhardwaremonitorlib.dll库文件 成功案例。
现有需求要在VB 6 编程环境下,使用openhardwaremonitorlib.dll库文件 ,
解决实时读取CPU和硬盘温度的需求。
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 Sub
using 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;
}
}
}
其他人如果也需要,可以从 https://download.csdn.net/download/caozhy/12683629 下载
https://blog.csdn.net/xjnzhidao/article/details/48105717
https://stackoverflow.com/questions/1404731/how-to-get-current-cpu-and-ram-usage-in-vb-6
https://stackoverflow.com/questions/31774626/how-can-i-see-temperature-of-cpu-using-vb-net-with-open-hardware-monitor-dll