91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

獲取機器memory和CPU信息的方法是什么

發布時間:2020-08-31 14:14:20 來源:億速云 閱讀:193 作者:小新 欄目:編程語言

小編給大家分享一下獲取機器memory和CPU信息的方法是什么,希望大家閱讀完這篇文章后大所收獲,下面讓我們一起去探討吧!

1. Use WMI to create connection to the computer passing username and password. Once the connection is created,  query the CPU& memory by passing the query, similar as SQL.  This way can get CPU & memory for remote PC and local PC. For example:

System.Management.ConnectionOptions Conn = new ConnectionOptions();

Conn.Username = mpusername;

Conn.Password = mppwd;

string scopestring = "//" + mpserver + "/root/cimv2";

System.Management.ManagementScope Ms = new ManagementScope(scopestring);

Ms.Connect();

mos.Scope = Ms;

ObjectQuery oq = new ObjectQuery();

oq.QueryString = "select * from Win32_Processor";

mos.Query = oq;

ManagementObjectCollection moc = mos.Get();

內存這塊花了比較多的時間,之前的對象已經過期,不能使用了,最后找到這個類“Win32_PerfRawData_PerfOS_Memory”

ManagementObjectCollection mcr = mcp.getQueryResult("select * from Win32_ComputerSystem");
           
           foreach (ManagementObject mo in mcr)
           {
               if (mo["TotalPhysicalMemory"] != null)
               {
                   totalm = long.Parse(mo["TotalPhysicalMemory"].ToString());
               }
           }
           ManagementObjectCollection moc = mcp.getQueryResult("select * from Win32_PerfRawData_PerfOS_Memory");
           foreach (ManagementObject mo in moc)
           {
               string avilable = mo.GetPropertyValue("AvailableBytes").ToString();
               avilablem = long.Parse(avilable);
           }

2. Get local server’s CPU and momory information passing the WMI classes, such as “Win32_Processor”, “Win32_OperatingSystem”

ManagementClass mc = new ManagementClass("Win32_OperatingSystem");

ManagementObjectCollection moc = mc.GetInstances();

3. Use performance counter to get performance data passing the performance counter name, such as monitor.PerformanceCounterFun("Processor", "_Total", "% Processor Time"). Normally we shoud get performance counter data several times, then use the average values.

看完了這篇文章,相信你對獲取機器memory和CPU信息的方法是什么有了一定的了解,想了解更多相關知識,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

驻马店市| 浪卡子县| 河池市| 乐陵市| 太康县| 丹凤县| 封开县| 涡阳县| 浮山县| 普安县| 饶河县| 临泽县| 明水县| 连平县| 甘谷县| 汾西县| 嘉禾县| 革吉县| 赣榆县| 天全县| 锦屏县| 柯坪县| 建昌县| 崇信县| 田阳县| 大方县| 云浮市| 凤台县| 镶黄旗| 西吉县| 久治县| 合川市| 济南市| 琼中| 新安县| 湖口县| 靖江市| 紫阳县| 崇州市| 车险| 永新县|