1

如何查看逻辑内存配置?

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"]);
        }
    }

在这段代码中似乎不起作用。并且编译没有错误。

4

1 回答 1

4

根据微软

Win32_LogicalMemoryConfiguration WMI 类不再可用于 Windows Vista。

文章建议您使用 ,Win32_OperatingSystem但最好使用 Process.GetCurrentProcess().

于 2012-07-20T12:06:49.840 回答