示例#1
0
        /// <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);
        }
示例#2
0
        /// <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);
        }
示例#3
0
 public static extern void GlobalMemoryStatus(ref MEMORY_INFO meminfo);