/// <summary> /// 获取内存占用率 /// </summary> /// <returns></returns> public static uint GetMenoryLoad() { MEMORY_INFO memInfo = new MEMORY_INFO(); MEMORYSTATUSEX memEx = new MEMORYSTATUSEX(); memEx.dwLength = (uint)Marshal.SizeOf(typeof(MEMORYSTATUSEX)); GlobalMemoryStatusEx(ref memEx); GlobalMemoryStatus(ref memInfo); return(memInfo.dwMemoryLoad); }
/// <summary> /// 获取内存信息 /// </summary> /// <returns></returns> public static MemoryInfo getMemoryInfo() { MEMORY_INFO memInfo = new MEMORY_INFO(); MEMORYSTATUSEX memEx = new MEMORYSTATUSEX(); memEx.dwLength = (uint)Marshal.SizeOf(typeof(MEMORYSTATUSEX)); GlobalMemoryStatusEx(ref memEx); GlobalMemoryStatus(ref memInfo); MemoryInfo memoryInfo = new MemoryInfo(); memoryInfo.memoryLoad = memInfo.dwMemoryLoad; memoryInfo.availPhys = memInfo.dwAvailPhys; memoryInfo.totalPhys = memInfo.dwTotalPhys; return(memoryInfo); }
public static extern void GlobalMemoryStatus(ref MEMORY_INFO meminfo);