[已解决]请高手改进一下3smile代码 直接输出 实际内存总数
本帖最后由 elexy 于 2011-10-10 08:39 编辑本段代码为 三笑 所写,为了解决32位系统发现不了 4G内存的问题,可这段代码输出的数组列表,能不能改一下,不要输出数组,输出一个变量,无论安装了多少内存,都将容量累加在一起。小弟水平有限,改不好。#include <array.au3>
$x=getmem()
_ArrayDisplay($x)
Func getmem()
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"
$Output=""
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PhysicalMemory", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) then
Local $mem,$k=1
For $objItem In $colItems
ReDim $mem[$k+1]
$output=Execute($objItem.Capacity)
$mem[$k]=$objItem.BankLabel
$mem[$k]=$output
$k+=1
Next
$mem=UBound($mem)-1
Return $mem
Else
Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_PhysicalMemory" )
Endif
EndFunc 本段代码为 三笑 所写,为了解决32位系统发现不了 4G内存的问题,可这段代码输出的数组列表,能不能改一下, ...
elexy 发表于 2011-10-2 10:17 http://www.autoitx.com/images/common/back.gif
不会吧?加个循环就解决了呀
#include <array.au3>
$x = getmem()
MsgBox(0, 0, $x)
Func getmem()
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"
$Output = ""
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PhysicalMemory", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
Local $mem, $k = 1, $Count = 0
For $objItem In $colItems
ReDim $mem[$k + 1]
$Output = Execute($objItem.Capacity)
$mem[$k] = $objItem.BankLabel
$mem[$k] = $Output
$k += 1
Next
$mem = UBound($mem) - 1
For $i = 0 To UBound($mem) - 1
$Count += $mem[$i]
Next
Return $Count
Else
MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_PhysicalMemory")
EndIf
EndFunc ;==>getmem
32位, >4g内存,读得出来?别说wmi,api里没函数支持 没有研究,好象win7 32位的可以,xp目前还没有相应的工具出世! 本帖最后由 netegg 于 2011-10-2 18:40 编辑
不管是什么系统,32位的寻址空间就到不了4g.
看下 http://blog.csdn.net/politefish/article/details/4592176 说的明白点
页:
[1]