public void Getmemory() { MEMORY_INFO MemInfo; MemInfo = new MEMORY_INFO(); getmemory.GlobalMemoryStatus(ref MemInfo); label3.Text = MemInfo.dwMemoryLoad.ToString() + "%的内存正在使用 "; label4.Text = "物理内存共有 " + MemInfo.dwTotalPhys / 1024 + "kb "; label5.Text = "可使用的物理内存有 " + MemInfo.dwAvailPhys / 1024 + "kb "; label6.Text = "交换文件总大小为 " + MemInfo.dwTotalPageFile / 1024 + "kb "; label7.Text = "尚可交换文件大小为 " + MemInfo.dwAvailPageFile / 1024 + "kb "; label8.Text = "总虚拟内存有 " + MemInfo.dwTotalVirtual / 1024 + "kb "; }
public static extern void GlobalMemoryStatus(ref MEMORY_INFO meminfo);