locked
How to get User Objects, GDI Objects,I/O Reads,I/O Writes using C# code for processes running on Desktop

    Question

  •  How to get User Objects, GDI Objects,I/O Reads,I/O Writes using C#.Net for processes running on Desktop
    • Changed type shiva_chary Tuesday, February 17, 2009 7:40 AM Issue with retrieving GDI Objects, I/O reads, I/O writes using C# code
    • Changed type shiva_chary Tuesday, February 17, 2009 7:40 AM Issue with retrieving GDI Objects, I/O reads, I/O writes using C# code
    Wednesday, February 11, 2009 5:41 AM

Answers

  • You can try the System.Diagnostics.Process.GetProcesses() method. 

    That will get you an array of Process objects and you can check the properties of each.

    You can also try this query using WMI:

    select * from CIM_Process


    That will get much of the info you are requesting as well, but the System.Diagnostics.Process class is simpler.

    Chris

    • Proposed as answer by Harry Zhu Friday, February 13, 2009 8:12 AM
    • Marked as answer by Harry Zhu Tuesday, February 17, 2009 6:06 AM
    • Unmarked as answer by shiva_chary Tuesday, February 17, 2009 7:31 AM
    • Marked as answer by Harry Zhu Wednesday, February 18, 2009 2:01 AM
    Wednesday, February 11, 2009 8:28 PM
  • Hi Chris,

    First of all thankyou for your solution.

    I am able to retrieve Process Name, ID, User name, Memory, Peak memory utilization etc from System.Diagnostics.Process.Getprocesses() method but I am unable to retrieve GDI Objects, I/O reads, I/O writes values of Task Manager from that Method.

    Please provide another alternative.

    Thankyou.


    Regards,
    Shiva
    • Marked as answer by shiva_chary Wednesday, March 18, 2009 3:00 PM
    Tuesday, February 17, 2009 9:41 AM
  • Hi,

    GetGuiResources Function can return the count of GDI objects.
    For more information about GetGuiResources Function please see:
    http://msdn.microsoft.com/en-us/library/ms683192(VS.85).aspx

    http://www.pinvoke.net/default.aspx/user32/GetGuiResources.html?DelayRedirect=1

    I/O reads and I/O writes can be found at  WriteOperationCount and  ReadOperationCount in Win32_Process .
    http://msdn.microsoft.com/en-us/library/aa394372(VS.85).aspx

    ManagementObjectSearcher can be used to search those WMI objects.

    Best regards,
    Harry


    http://www.codeplex.com/HelloWorld where you can find samples you are looking for
    • Marked as answer by Harry Zhu Wednesday, February 18, 2009 2:02 AM
    Wednesday, February 18, 2009 2:01 AM

All replies

  • You can try the System.Diagnostics.Process.GetProcesses() method. 

    That will get you an array of Process objects and you can check the properties of each.

    You can also try this query using WMI:

    select * from CIM_Process


    That will get much of the info you are requesting as well, but the System.Diagnostics.Process class is simpler.

    Chris

    • Proposed as answer by Harry Zhu Friday, February 13, 2009 8:12 AM
    • Marked as answer by Harry Zhu Tuesday, February 17, 2009 6:06 AM
    • Unmarked as answer by shiva_chary Tuesday, February 17, 2009 7:31 AM
    • Marked as answer by Harry Zhu Wednesday, February 18, 2009 2:01 AM
    Wednesday, February 11, 2009 8:28 PM
  • Hi Chris,

    First of all thankyou for your solution.

    I am able to retrieve Process Name, ID, User name, Memory, Peak memory utilization etc from System.Diagnostics.Process.Getprocesses() method but I am unable to retrieve GDI Objects, I/O reads, I/O writes values of Task Manager from that Method.

    Please provide another alternative.

    Thankyou.


    Regards,
    Shiva
    • Marked as answer by shiva_chary Wednesday, March 18, 2009 3:00 PM
    Tuesday, February 17, 2009 9:41 AM
  • Hi,

    GetGuiResources Function can return the count of GDI objects.
    For more information about GetGuiResources Function please see:
    http://msdn.microsoft.com/en-us/library/ms683192(VS.85).aspx

    http://www.pinvoke.net/default.aspx/user32/GetGuiResources.html?DelayRedirect=1

    I/O reads and I/O writes can be found at  WriteOperationCount and  ReadOperationCount in Win32_Process .
    http://msdn.microsoft.com/en-us/library/aa394372(VS.85).aspx

    ManagementObjectSearcher can be used to search those WMI objects.

    Best regards,
    Harry


    http://www.codeplex.com/HelloWorld where you can find samples you are looking for
    • Marked as answer by Harry Zhu Wednesday, February 18, 2009 2:02 AM
    Wednesday, February 18, 2009 2:01 AM