2017-5-8
10:35

root
root

[程序代码]VB 获取CPU温度示例

VERSION 5.00
Begin VB.Form Form1  
   Caption         =   "获取CPU温度"
   ClientHeight    =   3090
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3090
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1  
      Caption         =   "获取"
      Height          =   495
      Left            =   1440
      TabIndex        =   0
      Top             =   600
      Width           =   1455
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Download by http://www.NewXing.com
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
文章如需转载请注明:转载自: 紫灵幽梦
« 上一篇 下一篇 »

相关文章:

vb读取access并且显示  (2017-5-11 9:18:27)

VB程序逆向反汇编常见的函数   (2017-5-8 10:32:0)

VB内嵌汇编的模块示例  (2017-5-8 10:24:4)

内存数据的读写(PC)   (2017-3-1 17:51:40)

用VB制作外挂   (2017-3-1 16:16:53)

DoEvents函数   (2017-3-1 16:16:0)

发表留言: