是否可以通过Excel / Access VBA获取诸如DDR3 or DDR4
之类的物理内存DDR信息。我的下面的子例程给我有关物理内存的详细信息,但不提供任何DDR信息。
Sub RAMDetails()
Dim oWMISrvEx As Object
Dim oWMIObjSet As Object
Dim oWMIObjEx As Object
Dim oWMIProp As Object
Dim sWQL As String
Dim n
Dim sht As Worksheet
Set sht = ThisWorkbook.Sheets("Sheet1")
sWQL = "Select * From Win32_PhysicalMemory"
Set oWMISrvEx = GetObject("winmgmts:root/CIMV2")
Set oWMIObjSet = oWMISrvEx.ExecQuery(sWQL)
intRow = 2
strRow = Str(intRow)
sht.Range("A1").Value = "Name"
sht.Cells(1, 1).Font.Bold = True
sht.Range("B1").Value = "Value"
sht.Cells(1, 2).Font.Bold = True
For Each oWMIObjEx In oWMIObjSet
For Each oWMIProp In oWMIObjEx.Properties_
If Not IsNull(oWMIProp.Value) Then
If IsArray(oWMIProp.Value) Then
For n = LBound(oWMIProp.Value) To UBound(oWMIProp.Value)
Debug.Print oWMIProp.Name & "(" & n & ")", oWMIProp.Value(n)
sht.Range("A" & Trim(strRow)).Value = oWMIProp.Name
sht.Range("B" & Trim(strRow)).Value = oWMIProp.Value(n)
sht.Range("B" & Trim(strRow)).HorizontalAlignment = xlLeft
intRow = intRow + 1
strRow = Str(intRow)
Next
Else
sht.Range("A" & Trim(strRow)).Value = oWMIProp.Name
sht.Range("B" & Trim(strRow)).Value = oWMIProp.Value
sht.Range("B" & Trim(strRow)).HorizontalAlignment = xlLeft
intRow = intRow + 1
strRow = Str(intRow)
End If
End If
Next
Next
End Sub