本帖最后由 fpquenya 于 2012-6-25 09:40 编辑
回复 1# surongfu
;------------------------------
;查询物理内存信息(WMI方法)
;------------------------------
Local $oWMI,$colItems,$oFoundItem
$oWMI = ObjGet("winmgmts:\\.\root\cimv2")
$colItems = $oWMI.ExecQuery("SELECT TotalPhysicalMemory FROM Win32_ComputerSystem")
Local $iTotalMem
For $oFoundItem In $colItems
$iTotalMem = "内存总容量:" & Round($oFoundItem.TotalPhysicalMemory/1024/1024/1024,2) & "GB"
Next
Local $colMemory = $oWMI.ExecQuery("SELECT DeviceLocator,Manufacturer,Capacity,Speed,SerialNumber,TotalWidth FROM Win32_PhysicalMemory")
Local $iCount = $colMemory.Count ;内存条数量
Local $oMem,$sMemInfo
For $oMem In $colMemory
$sMemInfo = $sMemInfo & _
"内存厂商:" & StringStripWS($oMem.Manufacturer,1+2+4) & @CRLF & _
"单条容量:" & Round($oMem.Capacity/1024/1024/1024,1) & "GB" & @CRLF & _
"插槽位置:" & $oMem.DeviceLocator & @CRLF & _
"速度:" & $oMem.Speed & " MHz" & @CRLF & _
"序列号:" & StringStripWS($oMem.SerialNumber,1+2+4) & @CRLF & _
"总带宽:" & $oMem.TotalWidth & "位" & @CRLF
Next
MsgBox(0,"物理内存信息",$iTotalMem & @CRLF & "内存数量:" & $iCount & "条" & @CRLF & @CRLF & $sMemInfo)
修改一下,用所有内存条容量相加方法.
;------------------------------------------------------------
;精准查询物理内存信息(WMI方法)
;将所有内存条容量相+,避免32位系统只能识别3.25G内存的问题.
;------------------------------------------------------------
Local $oWMI,$colItems,$oFoundItem
$oWMI = ObjGet("winmgmts:\\.\root\cimv2")
;~ $colItems = $oWMI.ExecQuery("SELECT TotalPhysicalMemory FROM Win32_ComputerSystem")
;~ Local $iTotalMem
;~ For $oFoundItem In $colItems
;~ $iTotalMem = "内存总容量:" & Round($oFoundItem.TotalPhysicalMemory/1024/1024/1024,2) & "GB"
;~ Next
Local $colMemory,$iCount,$iCapacity,$oMem,$sMemInfo
$colMemory = $oWMI.ExecQuery("SELECT DeviceLocator,Manufacturer,Capacity,Speed,SerialNumber,TotalWidth FROM Win32_PhysicalMemory")
$iCount = $colMemory.Count ;内存条数量
$iCapacity = 0
For $oMem In $colMemory
$iCapacity = $iCapacity + Round($oMem.Capacity/1024/1024/1024,1) ;GB
$sMemInfo = $sMemInfo & _
"插槽位置:" & $oMem.DeviceLocator & @CRLF & _
"单条容量:" & Round($oMem.Capacity/1024/1024/1024,1) & "GB" & @CRLF & _
"内存厂商:" & StringStripWS($oMem.Manufacturer,1+2+4) & @CRLF & _
"速度:" & $oMem.Speed & " MHz" & @CRLF & _
"序列号:" & StringStripWS($oMem.SerialNumber,1+2+4) & @CRLF & _
"总带宽:" & $oMem.TotalWidth & "位" & @CRLF & @CRLF
Next
MsgBox(0,"物理内存信息","总容量:" & $iCapacity & "GB" & @CRLF & "内存数量:" & $iCount & "条" & @CRLF & @CRLF & $sMemInfo)
|