public static PerformanceInformation GetCurrent() { PerformanceInformation pi = new PerformanceInformation(); if (GetPerformanceInfo(out pi, Marshal.SizeOf(pi))) { return(pi); } else { throw new InvalidOperationException("GetPerformanceInfo returns false"); } }
public static int GetMemoryUsage() { var pi = PerformanceInformation.GetCurrent(); return((int)(100 * pi.CommitTotal / pi.PhysicalTotal)); }
public static extern bool GetPerformanceInfo([Out] out PerformanceInformation PerformanceInformation, [In] int Size);