How to find out how many slots/memory banks are being used in VB

Asked

Viewed 114 times

2

I am developing a project in Visual Basic and would like to know how I can read the amount of slots/ RAM banks there are in use in the computer, also the value of RAM installed in each slot/ bank in use, and the total RAM.

  • 1

    What is memory slot?

  • Type want to know how many memory combs my computer has, example: 2 comb 4 GB, totaling 8 GB

1 answer

3


inserir a descrição da imagem aqui


Welcome to OS/en

You can get the information using the WMI in his vbs:


strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory",,48)
Total_size = 0 
For Each objItem in colItems
    size = FormatNumber(objItem.Capacity/1024^3, 0)
    Wscript.Echo "Slot: " + objItem.BankLabel + vbNewLine + "Capacidade: " & size & "GB" & vbNewLine +  "Obs.: " + objItem.Tag
    Total_size= (Total_size + size)
Next
Wscript.Echo "Total de Ram: " & Total_size & "GB"

Or with a Slots counter in use:


inserir a descrição da imagem aqui


strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory",,48)
Total_Size = 0 
Total_Slot = 0
For Each objItem in colItems
    Size = FormatNumber(objItem.Capacity/1024^3, 0)
    If Size <> 0 Then
    Wscript.Echo "Slot: " + objItem.BankLabel + vbNewLine + "Capacidade: " & Size & "GB" & vbNewLine +  "Obs.: " + objItem.Tag
    Total_Size= (Total_Size + Size)
    Total_Slot= Total_Slot + 1
    End If
Next
Wscript.Echo "Slots em uso: " & Total_Slot & vbNewLine & "Total de Ram: " & Total_size & "GB"



Browser other questions tagged

You are not signed in. Login or sign up in order to post.