zoukankan      html  css  js  c++  java
  • Windows Monile 获取系统内存

    using System;
    using System.Text;
    using System.Runtime.InteropServices;
    
    namespace Kdt.CF.Utility
    {
        public class Memory
        {
            static MEMORYSTATUS status = new MEMORYSTATUS();
    
            #region P/V invoke
            private struct MEMORYSTATUS
            {
                public UInt32 dwLength;
                public UInt32 dwMemoryLoad;
                public UInt32 dwTotalPhys;
                public UInt32 dwAvailPhys;
                public UInt32 dwTotalPageFile;
                public UInt32 dwAvailPageFile;
                public UInt32 dwTotalVirtual;
                public UInt32 dwAvailVirtual;
            }
    
            [DllImport("CoreDll.dll")]
            private static extern void GlobalMemoryStatus
            (
                ref MEMORYSTATUS lpBuffer
            );
    
            [DllImport("CoreDll.dll")]
            private static extern UInt32 GetSystemMemoryDivision
            (
                ref UInt32 lpdwStorePages,
                ref UInt32 lpdwRamPages,
                ref UInt32 lpdwPageSize
            );
    
            #endregion
            /// <summary>
            /// 更新内存信息
            /// </summary>
            public static void UpdateStatus()
            {
                GlobalMemoryStatus(ref status);
            }
            /// <summary>
            /// 系统物理内存
            /// </summary>
            public static UInt32 TotalPhysicalMemory
            {
                get
                {
                    return status.dwTotalPhys;
                }
            }
            /// <summary>
            /// 可用物理内存
            /// </summary>
            public static UInt32 AvilablePhysicalMemory
            {
                get
                {
                    return status.dwAvailPhys;
                }
            }
            /// <summary>
            /// 系统虚拟内存
            /// </summary>
            public static UInt32 TotalVirtualMemory
            {
                get
                {
                    return status.dwTotalVirtual;
                }
            }
            /// <summary>
            /// 可用虚拟内存
            /// </summary>
            public static UInt32 AvilableVirtualMemory
            {
                get
                {
                    return status.dwAvailVirtual;
                }
            }
            /// <summary>
            /// 系统页
            /// </summary>
            public static UInt32 TotalPageFile
            {
                get
                {
                    return status.dwTotalPageFile;
                }
            }
            /// <summary>
            /// 可用页
            /// </summary>
            public static UInt32 AvilablePageFile
            {
                get
                {
                    return status.dwAvailPageFile;
                }
            }
        }
    }
  • 相关阅读:
    Oracle连接数一直在增
    ora00020: maximum number of processes (150) exeeded
    oracle归档日志满了
    C# ZPL
    error CS0227: 不安全代码只会在使用 /unsafe 编译的情况下出现
    最全zpl语言指令解析(含乱码)
    ZPL 打印机实例
    ora-01400 无法将NULL插入 ID 解决方法
    windows 选择时间控件(选择日期, 小时分钟秒)
    用户登陆检验----没有优化,大神可以帮忙优化优化
  • 原文地址:https://www.cnblogs.com/tryzi/p/2598951.html
Copyright © 2011-2022 走看看