高手帮帮忙!用wmi怎样知道一个进程的内存使用数值???
用那个查询发现有一个perrowdata什么的,但是里边的数值好像跟任务管理器不太一样!?

解决方案 »

  1.   

    参看
    http://www.codeproject.com/cs/system/wmi.asp返回的queryobject有这方面的属性
      

  2.   

    using System;
    using System.Management;
    using System.Windows.Forms;namespace WMISample
    {
        public class MyWMIQuery
        {
            public static void Main()
            {
                try
                {
                    ManagementObjectSearcher searcher = 
                        new ManagementObjectSearcher("root\\CIMV2", 
                        "SELECT * FROM Win32_Process");                 foreach (ManagementObject queryObj in searcher.Get())
                    {
                        Console.WriteLine("-----------------------------------");
                        Console.WriteLine("Win32_Process instance");
                        Console.WriteLine("-----------------------------------");
                        Console.WriteLine("Description: {0}", queryObj["Description"]);
                        Console.WriteLine("PeakWorkingSetSize: {0}", queryObj["PeakWorkingSetSize"]);
                        Console.WriteLine("WorkingSetSize: {0}", queryObj["WorkingSetSize"]);
                    }
                }
                catch (ManagementException e)
                {
                    MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
                }
            }
        }
    }WorkingSetSize/1024即可
      

  3.   

    多谢多谢!boylez(boylez) 和Knight94(愚翁) .解决了我一个大问题.