代码之家  ›  专栏  ›  技术社区  ›  Harun24hr

如何用Excel/Access vba检查物理内存(RAM)DDR类型?

  •  1
  • Harun24hr  · 技术社区  · 6 年前

    有没有办法得到物理内存DDR信息,比如 DDR3 or DDR4 通过Excel/Access VBA。我下面的子给我有关物理内存的详细信息,但不给任何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
    
    0 回复  |  直到 6 年前
    推荐文章