需要提供三个函数1、获取系统的总共物理内存(返回long型字节数)
2、获取系统当前使用的物理内存(返回long型字节数)
3、获取系统当前CPU使用率(返回double型,0到1之间)[email protected],哪位高手给个呀,谢谢谢谢谢谢谢谢
2、获取系统当前使用的物理内存(返回long型字节数)
3、获取系统当前CPU使用率(返回double型,0到1之间)[email protected],哪位高手给个呀,谢谢谢谢谢谢谢谢
解决方案 »
- 委托,Lambda 出错
- 检索COM类工厂中CLSID为{1F79A08F-62B2-4841-96B2-F9A21267BD7C}的组件时失败原因是出现以下错误:8007007e
- 多线程问题
- 字符串转换为执行语句的问题~~~~急~~~~在线等
- 用c#.NET做的托盘程序,在关机时由于该托盘的存在,计算机不能关机或重起。谁知道是什么原因?如何处理?
- 急急急,在线等,我要在DataGrid中添加一列,该列可以编辑。怎么做??
- command控件,如何使用参数和?
- 求教高手:如何获取系统托盘图标个数?
- OPC UA 收费吗?
- 有关事件和委托
- 怎样让母版页左边的链接的显示内容显示到ContentPlaceHolder区域呢?
- 用Process.Start打开一个外部程序,如果该程序跳到后台,怎样重新激活该程序,编程当前活跃窗体。而不是重新执行该程序
CPU使用率:http://topic.csdn.net/t/20051114/21/4393153.html自己把它改成Dll就可以了。
public partial class Form1 : Form
{
PerformanceCounter cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total"); public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
double cpu = getCurrentCpuUsage();
double Freemem = getAvailableRAM();
double usedMem = getCommitedRAM();
} public double getCurrentCpuUsage()
{
return cpuCounter.NextValue();
} /*
Call this method every time you need to get
the amount of the available RAM in Mb
*/
public double getAvailableRAM()
{
PerformanceCounter ramCounter = new PerformanceCounter("Memory", "Available Bytes");
return ramCounter.NextValue();
}
/*
Call this method every time you need to get
the amount of the available RAM in Mb
*/
public double getCommitedRAM()
{
PerformanceCounter ramCounter = new PerformanceCounter("Memory", "Committed Bytes");
return ramCounter.NextValue();
} }