Linked Questions

Popular Questions

i'm making a program to monitor hardware components and I am trying to get the RAM capacity of the desktop using the WMI Win32_ComptuterSystem class. I managed to get the amount of total RAM but it is displayed in bits instead of GB, I know i have to make a conversion but I have no idea how to go about it.

private void GetRamCapacity()
{
    var wmi = new ManagementClass("Win32_ComputerSystem");
    var providers = wmi.GetInstances();

    foreach (var provider in providers)
    {
        var ramCapacity = Convert.ToInt32(provider["TotalPhysicalMemory"]);

        lblRAMCapacity.Text = ramCapacity.ToString();         
    }
}

Related Questions