Reputation: 11
I've only seen examples for VB.NET. But I need to do this on VB6. Does anyone have examples or can do this? How can I see temperature of CPU using VB.NET with Open Hardware Monitor DLL
Can someone edit the code from VB.NET in VB6?
I realized that there are no built-in WinAPI functions for temperature and many uses a third-party dynamic library for this - OpenHardwareMonitorLib.dll . Where can I find all the functions of this library to use in VB6? In addition, the library was created in C# for .NET and 99.9% won't work on VB6! Perhaps there is another way to get the real temperature?
WMI - I don't consider it, because either it doesn't work, or it displays identical parameters
"wmic /namespace:\root\wmi PATH MSAcpi_ThermalZoneTemperature get Current Temperature"
PS: I think until someone writes a ready-made library for use(With a description of the functions), so these questions will appear to many in the future!
Upvotes: 1
Views: 409
Reputation: 9
You are mistaken. Visual Basic 6 and OHM will operate together, you just have to experiment connecting to WMI. There are many examples on the internet.
Public Sub getgblSensorArray(ByRef thisArray() As String, ByRef gblSensorCount As Integer)
' dimension all variables
Dim strComputer As String: strComputer = vbnullstring
Dim objSWbemLocator As Object
Dim objSWbemServices As Object
Dim colItems As Object
Dim objItem As Object
Dim thisSensorCount As Integer: thisSensorCount = 0
Dim I As Integer: I = 0
On Error GoTo getGblSensorArray_Error
strComputer = "." ' localhost
' connect to WMI
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer, "root\OpenHardwareMonitor")
' execute query on temperature sensors
Set colItems = objSWbemServices.ExecQuery("SELECT * FROM Sensor WHERE SensorType = 'Temperature'")
' extract the number of sensors
thisSensorCount = colItems.Count
' create an array containing the name and values of each sensor in the system
ReDim thisArray(thisSensorCount, 4) As String
For Each objItem In colItems
thisArray(I, 1) = objItem.Name
thisArray(I, 2) = objItem.Value
thisArray(I, 3) = objItem.Max
thisArray(I, 4) = objItem.Identifier
I = I + 1
Next
gblSensorCount = thisSensorCount
On Error GoTo 0
Exit Sub
getGblSensorArray_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure getGblSensorArray, line " & Erl & "."
End Sub
Upvotes: 0