zoukankan      html  css  js  c++  java
  • 获取系统内存大小(C#)

    代码如下:

            /// <summary>
            
    /// 获取系统内存大小
            
    /// </summary>
            
    /// <returns>内存大小(单位M)</returns>
            private static int GetPhisicalMemory()
            {
                ManagementObjectSearcher searcher 
    = new ManagementObjectSearcher();   //用于查询一些如系统信息的管理对象 
                searcher.Query = new SelectQuery("Win32_PhysicalMemory """new string[] { "Capacity" });//设置查询条件 
                ManagementObjectCollection collection = searcher.Get();   //获取内存容量 
                ManagementObjectCollection.ManagementObjectEnumerator em = collection.GetEnumerator();

                
    long capacity = 0;
                
    while (em.MoveNext())
                {
                    ManagementBaseObject baseObj 
    = em.Current;
                    
    if (baseObj.Properties["Capacity"].Value != null)
                    {
                        
    try
                        {
                            capacity 
    += long.Parse(baseObj.Properties["Capacity"].Value.ToString());
                        }
                        
    catch
                        {
                            
    return 0;
                        }
                    }
                }
                
    return (int)(capacity / 1024 / 1024);
            } 
  • 相关阅读:
    Markdown基本语法
    Hexo 集成 Gitalk 评论系统
    hexo添加百度统计
    tf.nn.softmax
    tf.InteractiveSession()与tf.Session()
    归一化、标准化、正则化的区别
    感受野的概念
    CNN中的low-level feature 与high-level feature
    安装vncserver后导致Ubuntu循环登录进入不了桌面的问题原因及解决办法
    python3 + Tensorflow + Faster R-CNN训练自己的数据
  • 原文地址:https://www.cnblogs.com/Aricc/p/1524675.html
Copyright © 2011-2022 走看看