Question: I'm investigating a possible memory leak which is causing an "Error creating window handle" Win32Exception in my .NET 2.0 WinForms app. This is related to number of Handles and number of USER objects (most likely) so I'm trying to log these metrics the next time the exception is thrown. 

HandleCount is easy to find: `Process.HandleCount`. 

Does anyone know how to find the Number of USER objects? (Value can be seen in a column of the Task Manager->Processes) .NET or win API functions will do.

Thanks!

Answer: 
Try [GetGuiResources](http://msdn.microsoft.com/en-us/library/ms683192(VS.85).aspx) which you can call using [P/Invoke](http://www.pinvoke.net/default.aspx/user32/GetGuiResources.html?DelayRedirect=1)
You can also see this in Windows Task Manager. 
1. Select "Process" tab.
2. Select View > "Select Columns..." and check "User Objects"