none
GDI object counts, user object counts for all processes including system idle process

    Question

  • Hi All,

    Using code, I am intersted to get list of GDI object counts, user object counts for all processes,

    System.Diagnostics.Process.Getprocesses() doesn't give these details.

    GetGuiResources method return the count of  user objects and GDI objects.

    But when I use it in my code

    Process.GetProcessById(processId).Handle, 0).ToString(); //0 for GDI counts

    it works in case of most of the services but fails (due to handle issue) for some key services like  System Idle process etc... (Access denied message occurs)

    Any other way to show objects of task managers in our programs ?

    Is

    Friday, March 02, 2012 4:33 AM

Answers

  • You will likely never find a way to get information from these processes. But for these two processes it should be easy to figure out how many handles they have open anyway, 0 User handles and 0 GDI handles. User handles are handles to user mode stuff like windows, accelerator tables and stuff, GDI handles are handles to things like bitmaps and fonts. So both of these have no real use in kernel mode. For a bit of information on these two processes.

    System Idle Process is a special process that does nothing but use up CPU time while there are no other threads waiting to execute. It literally does nothing but idles the processor to keep it cool. If you look at task manager you will notice that it always has 0 handles.

    System as the description of the process says is the "NT Kernel & System", so this is the kernel mode component of Windows. So while it is possible that this is where the objects themselves end up, this will not have any User or GDI handles open.


    This is a signature

    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    Friday, March 02, 2012 1:06 PM

All replies

  • You will likely never find a way to get information from these processes. But for these two processes it should be easy to figure out how many handles they have open anyway, 0 User handles and 0 GDI handles. User handles are handles to user mode stuff like windows, accelerator tables and stuff, GDI handles are handles to things like bitmaps and fonts. So both of these have no real use in kernel mode. For a bit of information on these two processes.

    System Idle Process is a special process that does nothing but use up CPU time while there are no other threads waiting to execute. It literally does nothing but idles the processor to keep it cool. If you look at task manager you will notice that it always has 0 handles.

    System as the description of the process says is the "NT Kernel & System", so this is the kernel mode component of Windows. So while it is possible that this is where the objects themselves end up, this will not have any User or GDI handles open.


    This is a signature

    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    Friday, March 02, 2012 1:06 PM
  • For task/resource management in Windows system, I think this project will be good for you: http://sourceforge.net/projects/processhacker/

    It also provide the svn address for providing the source codes.

     

    Mike Zhang[MSFT]
    MSDN Community Support | Feedback to us

    Monday, March 05, 2012 11:35 AM