Пример #1
0
    //  [DllImport("User32")]
    //  public static extern void GetWindowThreadProgressld (IntPtr hwnd,out int id);

    /// <summary>
    /// 检测内存是否溢出
    /// </summary>
    /// <returns></returns>
    private string GetMemoryStatus()
    {
        MEMORY_INFO MemInfo;

        MemInfo = new MEMORY_INFO();
        GlobalMemoryStatus(ref MemInfo);

        avaliableMemory = Convert.ToInt64(MemInfo.dwAvailPhys.ToString()) / 1024 / 1024;
        totalMemory     = Convert.ToInt64(MemInfo.dwTotalPhys.ToString()) / 1024 / 1024;

        var freeMemory = String.Format("FreeMomory: {0}/{1} MB", avaliableMemory, totalMemory);

        //Debug.Log(freeMemory);

        return(freeMemory);

        //print("FreeMemory:" + Convert.ToString(avaliableMb) + " MB");
        //if (avaliableMb < 200)
        //{
        //    Debug.Log("内存不足!");
        //    //弹出内存警告
        //}
        //else
        //{
        //    Debug.Log("可以使用");
        //    //自动取消内存警告
        //    Debug.Log(Environment.WorkingSet.ToString());

        //}
    }
Пример #2
0
        /// <summary>
        /// 获取内存信息
        /// </summary>
        /// <returns></returns>
        public static string GetMemoryInfo()
        {
            //调用GlobalMemoryStatus函数获取内存的相关信息
            MEMORY_INFO MemInfo = new MEMORY_INFO();
            GlobalMemoryStatus(ref MemInfo);

            StringBuilder sb = new StringBuilder();

            //*%的内存正在使用
            sb.Append(MemInfo.dwMemoryLoad.ToString() + "% of the memory is being used " + "\r\n");
            //总共的物理内存
            sb.Append("Physical memory total :" + Utility.ConvertBytes(MemInfo.dwTotalPhys.ToString(), 3) + "GB" + "\r\n");
            //可使用的物理内存
            sb.Append("Use of physical memory :" + Utility.ConvertBytes(MemInfo.dwAvailPhys.ToString(), 3) + "GB" + "\r\n");
            //交换文件总大小
            sb.Append("Total size of the swap file" + Utility.ConvertBytes(MemInfo.dwTotalPageFile.ToString(), 3) + "GB" + "\r\n");
            //尚可交换文件大小为
            sb.Append(" Can still swap file size :" + Utility.ConvertBytes(MemInfo.dwAvailPageFile.ToString(), 3) + "GB" + "\r\n");
            //总虚拟内存
            sb.Append("The Total virtual memory :" + Utility.ConvertBytes(MemInfo.dwTotalVirtual.ToString(), 3) + "GB" + "\r\n");
            //未用虚拟内存有
            sb.Append("Unused virtual memory :" + Utility.ConvertBytes(MemInfo.dwAvailVirtual.ToString(), 3) + "GB" + "\r\n");
            // ConvertBytes(totMem, 3) + " GB"
            return sb.ToString();
        }
Пример #3
0
        private ulong GetUsedMemory()
        {
            //取得已用掉的 ram
            MEMORY_INFO mi = GetMemoryStatus();

            return(mi.ullTotalPhys - mi.ullAvailPhys);
        }
Пример #4
0
 public static string SysPhycicalMemory { get; set; }    //物理内存
 public static void UpdateMemoryUsage()
 {
     MEMORY_INFO memoryInfo = new MEMORY_INFO();
     GlobalMemoryStatus(ref memoryInfo);
     SysMemoryUsage = memoryInfo.dwMemoryLoad.ToString();
     SysPhycicalMemory = (memoryInfo.dwTotalVirtual / 1024 / 1024).ToString() + "MB";
 }
Пример #5
0
        /// <summary>
        /// 获取内存信息
        /// </summary>
        /// <returns></returns>
        public static uint GetMemInfo()
        {
            //调用GlobalMemoryStatus函数获取内存的相关信息
            MEMORY_INFO MemInfo = new MEMORY_INFO();

            GlobalMemoryStatus(ref MemInfo);
            return(MemInfo.dwMemoryLoad);
        }
Пример #6
0
        //获取内存使用率
        public float GetMemeryRate()
        {
            MemInfo = new MEMORY_INFO();

            GlobalMemoryStatus(ref MemInfo);

            return(MemInfo.dwMemoryLoad);
        }
Пример #7
0
        public static float getMemoryStatus()
        {
            MEMORY_INFO MemInfo;

            MemInfo = new MEMORY_INFO();
            GlobalMemoryStatus(ref MemInfo);
            return(MemInfo.dwMemoryLoad);
        }
Пример #8
0
        }                                                       //物理内存
        public static void UpdateMemoryUsage()
        {
            MEMORY_INFO memoryInfo = new MEMORY_INFO();

            GlobalMemoryStatus(ref memoryInfo);
            SysMemoryUsage    = memoryInfo.dwMemoryLoad.ToString();
            SysPhycicalMemory = (memoryInfo.dwTotalVirtual / 1024 / 1024).ToString() + "MB";
        }
Пример #9
0
        private MEMORY_INFO GetMemoryStatus()
        {
            MEMORY_INFO mi = new MEMORY_INFO();

            mi.dwLength = (uint)System.Runtime.InteropServices.Marshal.SizeOf(mi);
            GlobalMemoryStatusEx(ref mi);
            return(mi);
        }
Пример #10
0
        private static MEMORY_INFO GetApiMemoryInfo()
        {
            MEMORY_INFO mi = new MEMORY_INFO();

            mi.dwLength = (uint)Marshal.SizeOf(mi);
            GlobalMemoryStatusEx(ref mi);
            return(mi);
        }
Пример #11
0
                /// <summary>
                /// 获取内存使用率
                /// </summary>
                /// <returns></returns>
                public static double GetMemoryUsing()
                {
                    MEMORY_INFO meminfo = new MEMORY_INFO();

                    GlobalMemoryStatus(ref meminfo);
                    var usingMem = meminfo.dwMemoryLoad;//内存使用率

                    return(usingMem);
                }
Пример #12
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);
        }
Пример #13
0
        private void GetInfo_Click()
        {
            //调用GetWindowsDirectory和GetSystemDirectory函数分别取得Windows路径和系统路径
            const int     nChars = 128;
            StringBuilder Buff   = new StringBuilder(nChars);

            ComputerInfo.GetWindowsDirectory(Buff, nChars);
            string Windows路径 = "Windows路径:" + Buff.ToString();

            ComputerInfo.GetSystemDirectory(Buff, nChars);
            string 系统路径 = "系统路径:" + Buff.ToString();
            //调用GetSystemInfo函数获取CPU的相关信息
            CPU_INFO CpuInfo;

            CpuInfo = new CPU_INFO();
            ComputerInfo.GetSystemInfo(ref CpuInfo);
            string CPU数量 =
                "本计算机中有" + CpuInfo.dwNumberOfProcessors.ToString() + "个CPU";
            string CPU的类型 = "CPU的类型为" + CpuInfo.dwProcessorType.ToString();

            string CPU等级 =
                "CPU等级为" + CpuInfo.dwProcessorLevel.ToString();
            string CPU的OEM = "CPU的OEM  ID为" + CpuInfo.dwOemId.ToString();
            string CPU中的页面 = "CPU中的页面大小为" + CpuInfo.dwPageSize.ToString();
            //调用GlobalMemoryStatus函数获取内存的相关信息
            MEMORY_INFO MemInfo;

            MemInfo = new MEMORY_INFO();
            ComputerInfo.GlobalMemoryStatus(ref MemInfo);
            string 内存正在使用   = MemInfo.dwMemoryLoad.ToString() + "%的内存正在使用";
            string 物理内存     = "物理内存共有" + MemInfo.ullTotalPhys.ToString() + "字节";
            string 可使用的物理内存 = "可使用的物理内存有" + MemInfo.ullAvailPhys.ToString() + "字节";

            string 交换文件总大小 =
                "交换文件总大小为" + MemInfo.ullTotalPageFile.ToString() + "字节";
            string 尚可交换文件大小 =
                "尚可交换文件大小为" + MemInfo.ullAvailPageFile.ToString() + "字节";
            string 总虚拟内存 =
                "总虚拟内存有" + MemInfo.ullTotalVirtual.ToString() + "字节";
            string 未用虚拟内存 =
                "未用虚拟内存有" + MemInfo.ullAvailVirtual.ToString() + "字节";
            //调用GetSystemTime函数获取系统时间信息
            SYSTEMTIME_INFO StInfo;

            StInfo = new SYSTEMTIME_INFO();
            ComputerInfo.GetSystemTime(ref StInfo);
            string 时间 =
                StInfo.wYear.ToString() + "年" + StInfo.wMonth.ToString() + "月" + StInfo.wDay.ToString() + "日";

            string 时间2 =
                (StInfo.wHour + 8).ToString() + "点" + StInfo.wMinute.ToString() + "分" + StInfo.wSecond.ToString() + "秒";
        }
Пример #14
0
        public static void GetMemoryStatus()
        {
            MEMORY_INFO MemInfo;

            MemInfo = new MEMORY_INFO();
            GlobalMemoryStatus(ref MemInfo);

            double totalMb     = double.Parse(MemInfo.dwTotalPhys.ToString()) / 1024 / 1024;
            double avaliableMb = double.Parse(MemInfo.dwAvailPhys.ToString()) / 1024 / 1024;

            Console.WriteLine("内存总量" + totalMb + " MB");
            Console.WriteLine("内存空闲" + avaliableMb + " MB");
        }
Пример #15
0
        public uint getRamUsePercent()
        {
            MEMORY_INFO MemInfo;

            MemInfo = new MEMORY_INFO();
            GlobalMemoryStatus(ref MemInfo);
            return(MemInfo.dwMemoryLoad);

            //PerformanceCounter ramCounter;
            //ramCounter = new PerformanceCounter("Memory", "Available MBytes");
            //return ramCounter.NextValue() + "MB";
            //return MemoryLoad;
        }
Пример #16
0
        /// <summary>
        /// 获得当前内存使用情况
        /// </summary>
        /// <returns></returns>
        public static MemoryInfo  GetMemoryStatus()
        {
            MEMORY_INFO mi = new MEMORY_INFO();

            mi.dwLength = (uint)Marshal.SizeOf(mi);
            GlobalMemoryStatusEx(ref mi);
            _memoryInfo.Free        = mi.ullAvailPhys;
            _memoryInfo.Total       = mi.ullTotalPhys;
            _memoryInfo.Used        = _memoryInfo.Total - _memoryInfo.Free;
            _memoryInfo.FreePercent = Math.Round(100f - (double.Parse(_memoryInfo.Used.ToString()) * 100.00 / double.Parse(_memoryInfo.Total.ToString())), 3);
            _memoryInfo.UpdateTime  = DateTime.Now;
            return(_memoryInfo);
        }
Пример #17
0
    /// <summary>
    /// 获取系统信息
    /// </summary>
    protected void GetSystemInfo()
    {
        try
        {
            OSVersion = Environment.OSVersion.ToString();

            IISVersion = Request.ServerVariables["SERVER_SOFTWARE"];

            if (OSVersion.IndexOf("Microsoft Windows NT 5.0") > -1)
            {
                OSVersion  = string.Concat("Microsoft Windows 2000 (", OSVersion, ")");
                IISVersion = "IIS 5";
            }
            else if (OSVersion.IndexOf("Microsoft Windows NT 5.1") > -1)
            {
                OSVersion  = string.Concat("Microsoft Windows XP (", OSVersion, ")");
                IISVersion = "IIS 5.1";
            }
            else if (OSVersion.IndexOf("Microsoft Windows NT 5.2") > -1)
            {
                OSVersion  = string.Concat("Microsoft Windows 2003 (", OSVersion, ")");
                IISVersion = "IIS 6";
            }
            else if (OSVersion.IndexOf("Microsoft Windows NT 6.0") > -1)
            {
                OSVersion  = string.Concat("Microsoft Windows Vista or Server 2008 (", OSVersion, ")");
                IISVersion = "IIS 7";
            }
            else if (OSVersion.IndexOf("Microsoft Windows NT 6.1") > -1)
            {
                OSVersion  = string.Concat("Microsoft Windows 7 or Server 2008 R2 (", OSVersion, ")");
                IISVersion = "IIS 7.5";
            }

            NETVersion = Environment.Version.ToString();

            CPUInfo = Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER") + " (" + Environment.ProcessorCount + " 核)";


            MEMORY_INFO MemInfo;
            MemInfo = new MEMORY_INFO();
            GlobalMemoryStatus(ref MemInfo);


            MemoryInfo = "物理内存:" + (MemInfo.dwTotalPhys / 1024 / 1024) + " MB / 当前程序已占用物理内存:" + (Environment.WorkingSet / 1024 / 1024).ToString() + " MB";
        }
        catch
        {
        }
    }
 protected void getRamStatus()
 {
     MEMORY_INFO MemInfo;
     MemInfo = new MEMORY_INFO();
     GlobalMemoryStatus(ref MemInfo);
     ramStatusStr = "<b>系统内存使用情况:</b><br/>内存使用率:<div class=\"graph\"><strong class=\"bar\" style=\"width:"
     + MemInfo.dwMemoryLoad.ToString() + "%;\">" + MemInfo.dwMemoryLoad.ToString() + "%</strong></div>物理内存共有"
         + (Convert.ToDouble(MemInfo.dwTotalPhys) / 1024 / 1024).ToString("N2") + "MB;<br/>可使用的物理内存有"
     + (Convert.ToDouble(MemInfo.dwAvailPhys) / 1024 / 1024).ToString("N2") + "MB;<br/>交换文件总大小为"
     + (Convert.ToDouble(MemInfo.dwTotalPageFile) / 1024 / 1024).ToString("N2") + "MB;<br/>尚可交换文件大小为"
     + (Convert.ToDouble(MemInfo.dwAvailPageFile) / 1024 / 1024).ToString("N2") + "MB;<br/>总虚拟内存有"
     + (Convert.ToDouble(MemInfo.dwTotalVirtual) / 1024 / 1024).ToString("N2") + "MB;<br/>未用虚拟内存有"
     + (Convert.ToDouble(MemInfo.dwAvailVirtual) / 1024 / 1024).ToString("N2") + "MB。";
 }
Пример #19
0
        public static MemoryInfo GetMemoryInfo()
        {
            MEMORY_INFO apiMemoryInfo = GetApiMemoryInfo();
            MemoryInfo  info          = new MemoryInfo(
                (int)apiMemoryInfo.dwLength,
                (long)apiMemoryInfo.ullTotalPhys,
                (long)apiMemoryInfo.ullAvailPhys,
                (long)apiMemoryInfo.ullTotalPageFile,
                (long)apiMemoryInfo.ullAvailPageFile,
                (long)apiMemoryInfo.ullTotalVirtual,
                (long)apiMemoryInfo.ullAvailVirtual);

            return(info);
        }
Пример #20
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);
        }
        /// <summary>
        /// 获取内存信息
        /// </summary>
        /// <param name="memoryInfo"></param>
        /// <param name="exceptionHandler"></param>
        /// <returns></returns>
        public static bool TryGetMemoryInfo(out MEMORY_INFO memoryInfo, Action <Exception> exceptionHandler = null)
        {
            memoryInfo = new MEMORY_INFO();
            try
            {
                GlobalMemoryStatus(ref memoryInfo);

                return(true);
            }
            catch (Exception e)
            {
                exceptionHandler?.Invoke(e);
                return(false);
            }
        }
Пример #22
0
        /// <summary>
        /// 调用API获取系统相关信息
        /// </summary>
        /// <returns></returns>
        public string initAPIData()
        {
            string info = "";
            //获取Windows路径
            const int     nChars = 128;
            StringBuilder buff   = new StringBuilder(nChars);

            GetWindowsDirectory(buff, nChars);
            info = string.Format("Windows路径:{0}\n", buff.ToString());

            //获取系统路径
            GetSystemDirectory(buff, nChars);
            info += string.Format("系统路径:{0}\n", buff.ToString());

            //获取CPU信息
            CPU_INFO cpuInfo = new CPU_INFO();

            GetSystemInfo(ref cpuInfo);
            info += string.Format(
                "\n本机中有{0}个CPU\nCPU类型为:{1}\nCPU等级为:{2}\nCPU的OEM ID为:{3}CPU的页面大小为:{4}\n",
                cpuInfo.dwNumOFProcessors.ToString(), cpuInfo.dwProcessorType.ToString(),
                cpuInfo.dwProcessorLevel.ToString(), cpuInfo.dwOemId.ToString(), cpuInfo.dwPageSize.ToString());

            //获取内存信息
            MEMORY_INFO memInfo = new MEMORY_INFO();

            GlobalMemoryStatus(ref memInfo);
            info += string.Format("内存正在使用{0}K\n", Math.Round(memInfo.dwMemoryLoad / (1.0 * 1024), 2).ToString());
            info += string.Format("物理内存共有{0}M\n", Math.Round(memInfo.dwTotalPhys / (1.0 * 1024 * 1024), 2).ToString());
            info += string.Format("可使用的物理内存共有{0}M\n", Math.Round(memInfo.dwAvailPhys / (1.0 * 1024 * 1024), 2).ToString());
            info += string.Format("交换文件总大小为{0}M\n", Math.Round(memInfo.dwTotalPageFile / (1.0 * 1024 * 1024), 2).ToString());
            info += string.Format("尚可交换文件大小为{0}M\n", Math.Round(memInfo.dwAvailPageFile / (1.0 * 1024 * 1024), 2).ToString());
            info += string.Format("总虚拟内存为{0}M\n", Math.Round(memInfo.dwTotalVirtual / (1.0 * 1024 * 1024), 2).ToString());
            info += string.Format("未用虚拟内存为{0}M\n", Math.Round(memInfo.dwAvailVirtual / (1.0 * 1024 * 1024), 2).ToString());

            //获取系统时间信息
            SYSTEMTIME_INFO stInfo = new SYSTEMTIME_INFO();

            GetSystemTime(ref stInfo);
            info += string.Format("\n系统时间:{0}年{1}月{2}日 星期{6} {3}时{4}分{5}秒",
                                  stInfo.wYear, stInfo.wMonth, stInfo.wDay, stInfo.wDayOfWeek,
                                  stInfo.wHour, stInfo.wMinute, stInfo.wMilliseconds);

            return(info);
        }
Пример #23
0
        /// <summary>
        /// 调用API获取系统相关信息
        /// </summary>
        /// <returns></returns>
        public string initAPIData()
        {
            string info = "";
            //获取Windows路径
            const int nChars = 128;
            StringBuilder buff = new StringBuilder(nChars);
            GetWindowsDirectory(buff, nChars);
            info = string.Format("Windows路径:{0}\n", buff.ToString());

            //获取系统路径
            GetSystemDirectory(buff, nChars);
            info += string.Format("系统路径:{0}\n", buff.ToString());

            //获取CPU信息
            CPU_INFO cpuInfo = new CPU_INFO();
            GetSystemInfo(ref cpuInfo);
            info += string.Format(
                "\n本机中有{0}个CPU\nCPU类型为:{1}\nCPU等级为:{2}\nCPU的OEM ID为:{3}CPU的页面大小为:{4}\n",
                cpuInfo.dwNumOFProcessors.ToString(), cpuInfo.dwProcessorType.ToString(),
                cpuInfo.dwProcessorLevel.ToString(), cpuInfo.dwOemId.ToString(), cpuInfo.dwPageSize.ToString());

            //获取内存信息
            MEMORY_INFO memInfo = new MEMORY_INFO();
            GlobalMemoryStatus(ref memInfo);
            info += string.Format("内存正在使用{0}K\n",Math.Round(memInfo.dwMemoryLoad / (1.0*1024),2).ToString());
            info += string.Format("物理内存共有{0}M\n", Math.Round(memInfo.dwTotalPhys / (1.0 * 1024 * 1024), 2).ToString());
            info += string.Format("可使用的物理内存共有{0}M\n", Math.Round(memInfo.dwAvailPhys / (1.0 * 1024 * 1024), 2).ToString());
            info += string.Format("交换文件总大小为{0}M\n", Math.Round(memInfo.dwTotalPageFile / (1.0 * 1024 * 1024), 2).ToString());
            info += string.Format("尚可交换文件大小为{0}M\n", Math.Round(memInfo.dwAvailPageFile / (1.0 * 1024 * 1024), 2).ToString());
            info += string.Format("总虚拟内存为{0}M\n", Math.Round(memInfo.dwTotalVirtual / (1.0 * 1024 * 1024), 2).ToString());
            info += string.Format("未用虚拟内存为{0}M\n", Math.Round(memInfo.dwAvailVirtual / (1.0 * 1024 * 1024), 2).ToString());

            //获取系统时间信息
            SYSTEMTIME_INFO stInfo = new SYSTEMTIME_INFO();
            GetSystemTime(ref stInfo);
            info += string.Format("\n系统时间:{0}年{1}月{2}日 星期{6} {3}时{4}分{5}秒",
                stInfo.wYear, stInfo.wMonth, stInfo.wDay, stInfo.wDayOfWeek,
                stInfo.wHour, stInfo.wMinute, stInfo.wMilliseconds);

            return info;
        }
Пример #24
0
 public static extern void GlobalMemoryStatus(ref MEMORY_INFO memInfo);
Пример #25
0
 public static extern string GlobalMemoryStatus(ref MEMORY_INFO meminfo);
Пример #26
0
        private void timer_Tick(object sender, EventArgs e)
        {
            if (pc == null)
            {
                pc = new PerformanceCounter("Processor", "% Processor Time", "_Total");
            }

            float cpu = 30f, mem = 0f;

            if (!firstRun)
            {
                cpu = (float)pc.NextValue();
            }



            MEMORYSTATUSEX stat = new MEMORYSTATUSEX();

            stat.dwLength = (uint)Marshal.SizeOf(typeof(MEMORYSTATUSEX));
            GlobalMemoryStatusEx(ref stat);

            //long ram = (long)stat.ullAvailPhys/1024/1024;
            //         Console.WriteLine(stat.ullAvailPhys/1024/1024);
            //         Console.WriteLine(stat.ullTotalPhys / 1024 / 1024);
            //         Console.WriteLine(stat.ullTotalVirtual / 1024 / 1024/1024);


            MEMORY_INFO MemInfo = new MEMORY_INFO();

            MemInfo.dwLength = (uint)Marshal.SizeOf(typeof(MEMORY_INFO));
            GlobalMemoryStatus(ref MemInfo);
            mem = (float)MemInfo.dwMemoryLoad;
            //Console.WriteLine(MemInfo.dwAvailPhys / 1024/1024);
            if (firstRun || percentOfCPU != cpu)
            {
                percentOfCPU = cpu;
                float i = (float)Math.Round(percentOfCPU * 2.5) - 125f;
                timerCPU.Enabled = false;
                if ((i >= -360) && (i <= 360))
                {
                    cpuAimAngle = i;
                }
                else
                {
                    cpuAimAngle = 0;
                }
                timerCPU.Enabled = true;
            }
            if (firstRun || percentOfMemory != mem)
            {
                percentOfMemory  = mem;
                timerMem.Enabled = true;
                float i = (float)Math.Round(percentOfMemory * 2.5) - 125f;
                timerMem.Enabled = false;
                memAimAngle      = i;
                timerMem.Enabled = true;
            }
            if (firstRun)
            {
                firstRun = false;
            }
        }
Пример #27
0
 public SystemInfo()
 {
     _oPerformanceCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
     MemInfo = new MEMORY_INFO();
     GlobalMemoryStatus(ref MemInfo);
 }
Пример #28
0
 private static extern void GlobalMemoryStatus(ref MEMORY_INFO meminfo);
Пример #29
0
        public uint getRamUsePercent()
        {
            MEMORY_INFO MemInfo;
            MemInfo = new MEMORY_INFO();
            GlobalMemoryStatus(ref MemInfo);
            return MemInfo.dwMemoryLoad;

            //PerformanceCounter ramCounter;
            //ramCounter = new PerformanceCounter("Memory", "Available MBytes");
            //return ramCounter.NextValue() + "MB";
            //return MemoryLoad;
        }
Пример #30
0
 public uint GetAvailPhys()
 {
     MEMORY_INFO MemInfo;
     MemInfo = new MEMORY_INFO();
     GlobalMemoryStatus(ref MemInfo);
     return MemInfo.dwAvailPhys;
 }
Пример #31
0
 private static extern void GlobalMemoryStatus(ref MEMORY_INFO meminfo);
Пример #32
0
    /// <summary>
    /// 获取系统信息
    /// </summary>
    protected void GetSystemInfo()
    {
        try
        {

            OSVersion = Environment.OSVersion.ToString();

            IISVersion = Request.ServerVariables["SERVER_SOFTWARE"];

            if (OSVersion.IndexOf("Microsoft Windows NT 5.0") > -1)
            {
                OSVersion = string.Concat("Microsoft Windows 2000 (", OSVersion, ")");
                IISVersion = "IIS 5";
            }
            else if (OSVersion.IndexOf("Microsoft Windows NT 5.1") > -1)
            {
                OSVersion = string.Concat("Microsoft Windows XP (", OSVersion, ")");
                IISVersion = "IIS 5.1";
            }
            else if (OSVersion.IndexOf("Microsoft Windows NT 5.2") > -1)
            {
                OSVersion = string.Concat("Microsoft Windows 2003 (", OSVersion, ")");
                IISVersion = "IIS 6";
            }
            else if (OSVersion.IndexOf("Microsoft Windows NT 6.0") > -1)
            {
                OSVersion = string.Concat("Microsoft Windows Vista or Server 2008 (", OSVersion, ")");
                IISVersion = "IIS 7";
            }
            else if (OSVersion.IndexOf("Microsoft Windows NT 6.1") > -1)
            {
                OSVersion = string.Concat("Microsoft Windows 7 or Server 2008 R2 (", OSVersion, ")");
                IISVersion = "IIS 7.5";
            }

            NETVersion = Environment.Version.ToString();

            CPUInfo = Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER") + " (" + Environment.ProcessorCount + " 核)";

            MEMORY_INFO MemInfo;
            MemInfo = new MEMORY_INFO();
            GlobalMemoryStatus(ref   MemInfo);

            MemoryInfo = "物理内存:" + (MemInfo.dwTotalPhys / 1024 / 1024 ) + " MB / 当前程序已占用物理内存:" + (Environment.WorkingSet / 1024 / 1024).ToString() + " MB";

        }
        catch
        {

        }
    }
Пример #33
0
 public static extern void GlobalMemoryStatus(ref MEMORY_INFO memInfo);
Пример #34
0
        public List<string> initAPIData()
        {
            List<string> lstAPI = new List<string>();
            CPU_INFO CpuInfo;
            CpuInfo = new CPU_INFO();
            GetSystemInfo(ref CpuInfo);
            //CPU��Ϣ�Ķ�ȡ�Ǵ����,�ұ�ֻ��һ��CPU,����������
            try
            {
                lstAPI.Add("CPU����:" + CpuInfo.dwNumberOfProcessors.ToString());
            }
            catch { }

            try
            {
                lstAPI.Add("CPU����:" + CpuInfo.dwProcessorType.ToString());
            }
            catch { }

            try
            {
                lstAPI.Add("CPU�ȼ�:" + CpuInfo.dwProcessorLevel.ToString());
            }
            catch { }

            try
            {
                lstAPI.Add("CPU�е�ҳ���С:" + CpuInfo.dwPageSize.ToString());
            }
            catch { }

            //����GlobalMemoryStatus������ȡ�ڴ�������Ϣ
            MEMORY_INFO MemInfo;
            MemInfo = new MEMORY_INFO();
            GlobalMemoryStatus(ref MemInfo);
            try
            {
                lstAPI.Add("����ʹ���ڴ�ռ���ڴ�ٷֱ�:" + MemInfo.dwMemoryLoad.ToString() + "%");
            }
            catch { }

            try
            {
                long dwTotalPhys = MemInfo.dwTotalPhys;
                dwTotalPhys = dwTotalPhys / 1000000;
                lstAPI.Add("�����ڴ湲��:" + dwTotalPhys.ToString() + " ��");
            }
            catch { }

            try
            {
                long dwAvailPhys = MemInfo.dwAvailPhys;
                dwAvailPhys = dwAvailPhys / 1000000;
                lstAPI.Add("��ʹ�õ������ڴ�:" + dwAvailPhys.ToString() + " ��");
            }
            catch { }

            try
            {
                long dwTotalPageFile = MemInfo.dwTotalPageFile;
                dwTotalPageFile = dwTotalPageFile / 1000000;
                lstAPI.Add("�����ļ��ܴ�С:" + dwTotalPageFile.ToString() + " ��");
            }
            catch { }

            try
            {
                long dwAvailPageFile = MemInfo.dwAvailPageFile;
                dwAvailPageFile = dwAvailPageFile / 1000000;
                lstAPI.Add("�пɽ����ļ���С:" + dwAvailPageFile.ToString() + " ��");
            }
            catch { }

            try
            {
                long dwTotalVirtual = MemInfo.dwTotalVirtual;
                dwTotalVirtual = dwTotalVirtual / 1000000;
                lstAPI.Add("�������ڴ�:" + dwTotalVirtual.ToString() + " ��");
            }
            catch { }

            try
            {
                long dwAvailVirtual = MemInfo.dwAvailVirtual;
                dwAvailVirtual = dwAvailVirtual / 1000000;
                lstAPI.Add("δ�������ڴ�:" + dwAvailVirtual.ToString() + " ��");
            }
            catch { }

            //����GetSystemTime������ȡϵͳʱ����Ϣ
            SYSTEMTIME_INFO StInfo;
            StInfo = new SYSTEMTIME_INFO();
            GetSystemTime(ref StInfo);
            lstAPI.Add("������ʱ��:" + StInfo.wYear.ToString() + "��" + StInfo.wMonth.ToString() + "��" + StInfo.wDay.ToString() + "��" + (StInfo.wHour + 8).ToString() + "��" + StInfo.wMinute.ToString() + "��" + StInfo.wSecond.ToString() + "��");
            return lstAPI;
        }
Пример #35
0
 public static extern bool GlobalMemoryStatusEx(ref MEMORY_INFO mi);
Пример #36
0
        /// <summary>
        /// 获得当前总计物理内存大小
        /// </summary>
        /// <returns&amp;gt;总计物理内存大小(B)&amp;lt;/returns&amp;gt;
        public static ulong GetTotalPhys()
        {
            MEMORY_INFO mi = GetMemoryStatus();

            return(mi.ullTotalPhys);
        }