Advertisement
a5768549

Untitled

Aug 6th, 2019
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.72 KB | None | 0 0
  1. Imports System
  2.  
  3. Imports System.Management
  4.  
  5.  
  6.  
  7. Public Class Form1
  8.  
  9.  
  10.  
  11.     Private Sub Button1_Click(ByVal s As Object, ByVal e As EventArgs) Handles Button1.Click
  12.  
  13.  
  14.  
  15.         Dim CPUtprt As Integer = CPU_Temperature()
  16.  
  17.         MessageBox.Show("CPU 溫度: " & CPU_Temperature() & " °C")
  18.  
  19.  
  20.  
  21.     End Sub
  22.  
  23.  
  24.  
  25.     ' 取得CPU 溫度
  26.  
  27.     Private Function CPU_Temperature() As Integer
  28.  
  29.         Dim Q As String = "Select * From MSAcpi_ThermalZoneTemperature"
  30.  
  31.         Dim mos As New ManagementObjectSearcher("root\WMI", Q)
  32.  
  33.         For Each mo As ManagementObject In mos.Get
  34.  
  35.             Return Convert.ToInt32(mo.GetPropertyValue("CurrentTemperature") - 2732) / 10
  36.  
  37.         Next
  38.  
  39.     End Function
  40.  
  41.  
  42.  
  43. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement