/// <summary> /// 获取当前计算机的内存状态。 /// </summary> /// <returns>该操作如果无异常,则会返回一个包含内存信息和状态的结构。</returns> public static SMemoryStatus GetMemoryStatus() { SMemoryStatus status = new SMemoryStatus { Length = (uint)Marshal.SizeOf(typeof(SMemoryStatus)), MemoryLoad = 0, TotalPhysicalMemory = 0, AvailablePhysicalMemory = 0, TotalPageFile = 0, AvailablePageFile = 0, TotalVirtualMemory = 0, AvailableVirtualMemory = 0, AvailableExtendedVirtualMemory = 0 }; GlobalMemoryStatusEx(ref status); return(status); }
private static extern bool GlobalMemoryStatusEx(ref SMemoryStatus buffer);