用WMI不能获取CPU的温度,求解决
用WMI可以获取硬盘温度,但是显示CPU温度为空,我用的是Win 7系统,Autoit版本3.3.7。有大神指点下这是为什么,怎么解决啊。。。MsgBox(0,'',_ACPI_Temp())
MsgBox(0,'',_WMI_DriveTemperature())
Func _ACPI_Temp() ;CPU Temp
Local $wbemFlagReturnImmediately = 0x10, $strComputer, $objWMIService, $colItems, $CurrTemp
Local $wbemFlagForwardOnly = 0x20
$strComputer = "."
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\wmi")
$colItems = $objWMIService.ExecQuery("SELECT * FROM MSAcpi_ThermalZoneTemperature", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
For $objItem In $colItems
$CurrTemp = ($objItem.CurrentTemperature - 2732) / 10
Next
Return $CurrTemp
EndFunc
Func _WMI_DriveTemperature() ; Hard Drive temp
Local $wbemFlagReturnImmediately = 0x10, $objWMIService, $colItems, $colTemp , $strComputer, $objItem, $s
Local $wbemFlagForwardOnly = 0x20
Local $strVendorSpecific
$strComputer = "."
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\wmi")
$colTemp = $objWMIService.ExecQuery('SELECT * FROM MSStorageDriver_ATAPISmartData', "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
For $objItem In $colTemp
$strVendorSpecific = $objItem.VendorSpecific
For $i = 2 To UBound($strVendorSpecific) - 1 Step 12
If $strVendorSpecific[$i] = 0xC2 Then ; find Vendor Parameter #194 - Temperatur
$s &= " " & $strVendorSpecific[$i + 5] ; Raw/Value celsuis
ContinueLoop 2
EndIf
Next
For $i = 2 To UBound($strVendorSpecific) - 1 Step 12
If $strVendorSpecific[$i] = 0xBE Then ; find Vendor Parameter #190 - Airflow Temperatur (if no tempetature is found)
$s &= " " & $strVendorSpecific[$i + 5] ; Raw/Value celsuis
ContinueLoop 2
EndIf
Next
If $s = 0 or $s = "N/A" or $s = "" or $s = @error then
$s = $strVendorSpecific
Endif
Next
Return $s
EndFunc 回复 1# zxhou1
加 #RequireAdmin 试试 {:face (327):}呵呵!顶 回复 2# lixiaolong
不行啊,我在xp系统运行都没问题的,win7就不行了 求解决啊,大神 学习一下如何操作 谢分享,学习下
页:
[1]