如果能获取到远程计算机的更好~
谢谢了~
最好贴相关代码,谢谢!

解决方案 »

  1.   

    NtQuerySystemInformation() //进程信息(包括CPU使用)
      

  2.   

    WMI?能不能具体点?谢谢,
    获取本地的就可以了。谢谢
    NtQuerySystemInformation() ?
    能不能具体点?包括类名空间,使用方法?谢谢了~~~~~再次感谢 !
      

  3.   

    System.Diagnostics.PerformanceCounter performanceCounter1;
    performanceCounter1 = new System.Diagnostics.PerformanceCounter();
    performanceCounter1.CategoryName = "Processor";
    performanceCounter1.CounterName = "% Processor Time";
    performanceCounter1.InstanceName = "_Total";
    performanceCounter1.MachineName = "."; //本机
    performanceCounter1.NextValue(); //cpu占用率
      

  4.   

    vosov(ask a favor of wind...) give an answer in the correct way! Thanks!
      

  5.   

    private string Cpu()
    {
    System.Diagnostics.PerformanceCounter performanceCounter1;
    performanceCounter1 = new System.Diagnostics.PerformanceCounter();
    performanceCounter1.CategoryName = "Processor";
    performanceCounter1.CounterName = "% Processor Time";
    performanceCounter1.InstanceName = "_Total";
    performanceCounter1.MachineName = "."; //本机
    return performanceCounter1.NextValue().ToString(); //cpu占用率
    }//这里我用一个时钟控件让它每秒更新一次,并输出到label2上
    private void timer1_Tick(object sender, System.EventArgs e)
    {
    this.label2.Text = Cpu();
    }//最后结果是总是显示为"0",是哪里出了问题呢?能不能更详细地把那些参数说明了一下?
    //再次感谢
      

  6.   

    performanceCounter1定义为类成员。初始化在类的构造函数里做。Cpu()函数里应该只有一句:return this.performanceCounter1.NextValue().ToString();
      

  7.   

    非常感谢!!修改后如下:private PerformanceCounter PC = new PerformanceCounter();private void Form1_Load(object sender, System.EventArgs e)
    {
    PC.CategoryName = "Process";
    PC.CounterName = "% Processor Time";
    PC.InstanceName = "_Total";
    PC.MachineName = ".";
    this.timer1.Interval = 1000;
    this.timer1.Enabled = true;
    }private void timer1_Tick(object sender, System.EventArgs e)
    {
    this.label2.Text = PC.NextValue().ToString()+"%";
    }但label2的值大部分时间都维持在100%,偶尔出现98%,与实际的很不相符。
    查过MSDN相关,PC.CounterName 也有一个Private Byte属性,即
    PC.CounterName = "Private Byte";
    得到的结果好像是一个16进制的数~~~
    不知道到底哪里出错了呢?谢谢~~~~~~
      

  8.   

    不好意思。 CategoryName 应该是 "Processor";
      

  9.   

    嗯!我过来就是想告诉你,Process少了or,
    哈哈,成功了!
    真是非常感谢你!
    可惜我的分太少,有点对不住~~
    从心底感谢各位,特别是vosov!
    谢谢·!
      

  10.   

    是少了or~~
    Processor
    就能正常获取,否则总是显示100%