locked
How can I obtain the process page faults RRS feed

  • Question

  • Hello,

    I am trying to write my own task manager and i can't seem to find the Page Fault property for each of the processes.
    Is there a way to retrieve this information?
    Thursday, December 10, 2009 11:07 AM

Answers

  • i have found this article Scott Lysle at http://www.c-sharpcorner.com/UploadFile/scottlysle/FindListProcessesCS09102007024714AM/FindListProcessesCS.aspx

    much thanks Scott!!!!!!

    this is his example:

    /// <summary>

    /// Returns a string containing information on running processes

    /// </summary>

    /// <param name="tb"></param>

    public static string ListAllProcesses()

    {

        StringBuilder sb = new StringBuilder();

     

        // list out all processes and write them into a stringbuilder

        ManagementClass MgmtClass = new ManagementClass("Win32_Process");

       

        foreach (ManagementObject mo in MgmtClass.GetInstances())

        {

            sb.Append("Name:\t" + mo["Name"] + Environment.NewLine);

            sb.Append("ID:\t" + mo["ProcessId"] + Environment.NewLine);

            sb.Append(Environment.NewLine);

        }

        return sb.ToString();

    }


    what i have have changed is:


            sb.Append("ID:\t" + mo["ProcessId"] + Environment.NewLine);


    to:


            sb.Append("ID:\t" + mo["PageFaults"] + Environment.NewLine);

    • Marked as answer by Bin-ze Zhao Tuesday, December 15, 2009 6:41 AM
    Thursday, December 10, 2009 2:49 PM