如何取得WMI信息.(50分)

  • 主题发起人 主题发起人 ZBJ2001_KF
  • 开始时间 开始时间
Z

ZBJ2001_KF

Unregistered / Unconfirmed
GUEST, unregistred user!
本想通过软件调用CPU的温度,查资料发现说是可以通过WMI得到CPU或主板的温度,包括CPU风扇转速, 谢谢指教
 
为什么没人参与啊
 
高科技的东西……
 
也谈不上.我见vb中有这样的代码.大家帮我看看<br><br>VB.Net 使用 WMI ( Windows Management Instrumentation ) 來取得 CPU 溫度<br><br>&nbsp;<br><br>&lt;&lt; VB.Net &gt;&gt;<br><br>&nbsp;<br><br>請先加入參考 System.Management<br><br>&nbsp;<br><br>Imports System<br><br>Imports System.Management<br><br>&nbsp;<br><br>Public Class Form1<br><br>&nbsp;<br><br>&nbsp; &nbsp; Private Sub Button1_Click(ByVal s As Object, ByVal e As EventArgs) Handles Button1.Click<br><br>&nbsp;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; Dim CPUtprt As Integer = CPU_Temperature()<br><br>&nbsp;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; If CPUtprt &gt;= 100 Then<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox.Show("CPU 溫度: " &amp; CPUtprt.ToString &amp; " °C" &amp; ControlChars.CrLf &amp; _<br><br>"溫度破錶嚕! 快準備煎蛋囉! " &amp; ControlChars.CrLf &amp; _<br><br>"或開啟自動灑水系統降溫喔!")<br><br>&nbsp; &nbsp; &nbsp; &nbsp; Else<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox.Show("CPU 溫度: " &amp; CPU_Temperature() &amp; " °C")<br><br>&nbsp; &nbsp; &nbsp; &nbsp; End If<br><br>&nbsp;<br><br>&nbsp; &nbsp; End Sub<br><br>&nbsp;<br><br>&nbsp; &nbsp; ' 取得CPU 溫度<br><br>&nbsp; &nbsp; Private Function CPU_Temperature() As Integer<br><br>&nbsp; &nbsp; &nbsp; &nbsp; Dim Q As String = "Select * From MSAcpi_ThermalZoneTemperature"<br><br>&nbsp; &nbsp; &nbsp; &nbsp; Dim mos As New ManagementObjectSearcher("root/WMI", Q)<br><br>&nbsp; &nbsp; &nbsp; &nbsp; For Each mo As ManagementObject In mos.Get<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return Convert.ToInt32(mo.GetPropertyValue("CurrentTemperature") - 2732) / 10<br><br>&nbsp; &nbsp; &nbsp; &nbsp; Next<br><br>&nbsp; &nbsp; End Function<br><br>&nbsp;<br><br>End Class<br><br>&nbsp;<br><br><br><br>&nbsp;<br><br>&nbsp;<br><br>' ================================================================<br><br>&nbsp;<br><br>&nbsp;<br><br>&lt;&lt; VB6 &gt;&gt;<br><br>&nbsp;<br><br>Private Sub Command1_Click()<br><br>&nbsp;<br><br>&nbsp; &nbsp; MsgBox "CPU 溫度 : " &amp; CPU_Temperature &amp; " °C"<br><br>&nbsp; &nbsp;<br><br>End Sub<br><br>&nbsp;<br><br>Private Function CPU_Temperature() As Integer<br><br>&nbsp;<br><br>&nbsp; &nbsp; Dim WMIsvc As Object<br><br>&nbsp; &nbsp; Dim CltItems As Object, CltItem As Object<br><br>&nbsp; &nbsp; Dim Q As String
 
在微软网站的脚本中心就有.
 
其实我也很想知道
 
现在很多系统测试软件都有这样的功能
 
不问了.要结贴了.
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
后退
顶部