如何查看逻辑内存配置?
private void button1_Click(object sender, EventArgs e)
{
ObjectQuery winQuery = new ObjectQuery("SELECT * FROM Win32_LogicalMemoryConfiguration");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(winQuery);
foreach (ManagementObject item in searcher.Get())
{
textBox1.Text =("Total Space = " + item["TotalPageFileSpace"]);
textBox2.Text = ("Total Physical Memory = " + item["TotalPhysicalMemory"]);
textBox3.Text = ("Total Virtual Memory = " + item["TotalVirtualMemory"]);
textBox4.Text = ("Available Virtual Memory = " + item["AvailableVirtualMemory"]);
}
}
在此代码中似乎不起作用。并且编译没有错误。
请您参考如下方法:
根据 Microsoft
The Win32_LogicalMemoryConfiguration WMI class is no longer available for use as of Windows Vista.
文章建议您使用 Win32_OperatingSystem,但您最好使用 Process.GetCurrentProcess()。
