VB 如何得到CPU温度呢?
PublicFunctionGetCPUTemp()AsDoubleDimiAsIntegerDimmCPUAsVariantDimuAsVariantDimsAsStr...
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()
Timer1.Interval = 500
End Sub
Private Sub Timer1_Timer()
Print GetCPUTemp()
End Sub
这段代码要通过WMI来实现,但有些主板不支持WMI的,所以要用其他方法,有没有知道的呢 展开
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()
Timer1.Interval = 500
End Sub
Private Sub Timer1_Timer()
Print GetCPUTemp()
End Sub
这段代码要通过WMI来实现,但有些主板不支持WMI的,所以要用其他方法,有没有知道的呢 展开
2个回答
展开全部
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()
Timer1.Interval = 500
End Sub
Private Sub Timer1_Timer()
Print GetCPUTemp()
End Sub
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()
Timer1.Interval = 500
End Sub
Private Sub Timer1_Timer()
Print GetCPUTemp()
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询