- Private Sub Command1_Click()
-
- MsgBox "CPU 温度 : " & CPU_Temperature & " C"
-
- End Sub
-
- Private Function CPU_Temperature() As Integer
-
- Dim WMIsvc As Object
-
- Dim CltItems As Object, CltItem As Object
-
- Dim Q As String
-
- Set WMIsvc = GetObject("winmgmts:\\.\root\WMI")
-
- Q = "SELECT * FROM MSAcpi_ThermalZoneTemperature"
-
- Set CltItems = WMIsvc.ExecQuery(Q, , 48)
-
- For Each CltItem In CltItems
-
- CPU_Temperature = CltItem.CurrentTemperature
-
- Next
-
- CPU_Temperature = (CPU_Temperature - 2732) / 10
-
- Set CltItem = Nothing
-
- Set CltItems = Nothing
-
- Set WMIsvc = Nothing
-
- End Function
复制代码
|