VB如何访问注册表以获得CPU概括温度
需以管理员身份运行!
Dim LX As Integer, LY As Integer, MX As Integer, MY As Integer, BM As Boolean
Public Function GetCPUTemp() As Double
Dim i As Integer
Dim mCPU As Variant
Dim u As Variant
Dim s As String
Set mCPU = GetObject("WINMGMTS:{impersonationLevel=impersonate}!root\wmi").ExecQuery("SELECT CurrentTemperature From MSAcpi_ThermalZoneTemperature")
For Each u In mCPU
s = s & u.CurrentTemperature
Next
Set mCPU = Nothing
GetCPUTemp = (s - 2732) / 10
End Function
Private Sub Form_Load()
print GetCPUTemp()
'如需循环侦测请使用Timer
End Sub