我想在内存的控制台上写入包括已安装的ram和可用的ram: 例如:安装内存:4,00 GB(可用3,80 GB)。 目前,我确实得到了#4;安装内存:4,00 GB"
public static void GetInstalledMemoryInfor()
{
ObjectQuery query = new ObjectQuery("SELECT Capacity FROM Win32_PhysicalMemory");
ManagementObjectSearcher mos = new ManagementObjectSearcher(query);
UInt64 capacity = 0;
foreach (ManagementObject WmiObject in mos.Get())
{
capacity += (UInt64)WmiObject["Capacity"];
}
Console.WriteLine(String.Format("Installed memory (RAM): {0:N} GB", capacity / (1024 * 1024 * 1024)));
}
如何获得可用的ram?谢谢4帮助我?
答案 0 :(得分:0)
3天后问了同样的问题并回答了。
TotalPhysicalMemory from VisualBasic.Devices slightly different from WMI Win32_PhysicalMemory
总结:win32_ComputerSYstem.TotalPhysicalMemory就是您的追求