![](/img/trans.png)
[英]how to get the All the Checkbox values in TreeView control in C#.net(2010) Windows Forms Application?
[英]How to get System Memory in C#.net windows application?
我正在網絡連接的系統上進行構建檢查和安裝。
如何在C#.net Windows應用程序中獲取系統內存?
提前致謝。
您可以使用性能計數器來獲取它。嘗試使用以下代碼段。
using System.Diagnostics;
protected PerformanceCounter ramCounter;
ramCounter = new PerformanceCounter("Memory", "Available MBytes");
/*
Call this method every time you need to get
the amount of the available RAM in Mb
*/
public string getAvailableRAM()
{
return ramCounter.NextValue().ToString() +"Mb";
}
是的,@ neil的鏈接是很好的資源
我認為您可以將其用於可用內存,其他用戶也可以使用
PerformanceCounter availableBytes = new PerformanceCounter("Memory","Available Bytes", true);
double numBytes = availableBytes.RawValue / 1024 /1024; // Mb
availableBytes.Close();
或者,您可以為此代碼添加參考Visual Basic並添加Microsoft.VisualBasic.Devices
var Available = new ComputerInfo().AvailablePhysicalMemory;
var Total = new ComputerInfo().TotalPhysicalMemory;
調用GlobalMemoryStatus並檢查返回的結構。
您可以從C#中的性能計數器獲取數據,其中許多是已使用的系統內存。 這是有關如何執行此操作的文章:
http://msdn.microsoft.com/zh-CN/library/s155t6ta(v=vs.71).aspx
當然,一旦完成這項工作,就可以相對輕松地開始為您的應用獲取各種其他功能。 例如,如果它實際上是所需的總可用內存或磁盤I / O。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.