Click here to Skip to main content
15,891,033 members
Home / Discussions / C#
   

C#

 
AnswerRe: Max member of ArrayList? Pin
garyshort18-Sep-07 23:12
garyshort18-Sep-07 23:12 
AnswerRe: Max member of ArrayList? Pin
Dave Kreskowiak19-Sep-07 5:17
mveDave Kreskowiak19-Sep-07 5:17 
QuestionSocket Connection, help me please!!!! Pin
Vampire1986hieu18-Sep-07 21:47
Vampire1986hieu18-Sep-07 21:47 
AnswerRe: Socket Connection, help me please!!!! Pin
garyshort18-Sep-07 23:15
garyshort18-Sep-07 23:15 
AnswerRe: Socket Connection, help me please!!!! Pin
ramdil19-Sep-07 0:32
ramdil19-Sep-07 0:32 
GeneralRe: Socket Connection, help me please!!!! Pin
Vampire1986hieu20-Sep-07 16:11
Vampire1986hieu20-Sep-07 16:11 
QuestionHelp on pinvoke functions Pin
izakfick18-Sep-07 21:43
izakfick18-Sep-07 21:43 
NewsFeedback: How to find the number of current window handles [modified] Pin
Martin#18-Sep-07 21:27
Martin#18-Sep-07 21:27 
Hello community,

I just wanted to give a feedback, regarding to my question some days ago:My Question from 14. Sept[^]
There I was facing a Win32Exception, "Error creating window handle".

At this place I want to thank mav.northwind[^] for his great help!

He pointed me to the "User32.dll" method "GetGuiResources" (msdn documentation[^]),
which was exactly what I was looking for.
/// uiFlags: 0 - Count of GDI objects
/// uiFlags: 1 - Count of USER objects
/// - Win32 GDI objects (pens, brushes, fonts, palettes, regions, device contexts, bitmap headers)
/// - Win32 USER objects:
/// - WIN32 resources (accelerator tables, bitmap resources, dialog box templates, font resources,
///   menu resources, raw data resources, string table entries, message table entries, cursors/icons)
/// - Other USER objects (windows, menus)
[DllImport("User32")]
extern public static int GetGuiResources(IntPtr hProcess, int uiFlags);

This method is able to return two values as you can see:
0 - Count of GDI objects:	Is the one you also can watch over the taskmanager.
1 - Count of USER objects:	Is not neccessary equal to the GDI Objects
			and AFAIK not visible in the taskmanager.

An example, how the counting works:
If you place a UserControl on a form

1) a naked UserControl:				GDI +1; User +1
2) a UserControl which holds a "PictureBox":		GDI +1; User +2
3) a UserControl which holds a "System.Drawing.Pen":	GDI +2; User +1
4) 2) + 3):					GDI +3; User +2, ???
		sometimes it returns:		GDI +2; User +2, which would be expected)

I knew that there is a limit set in the Registry for the GDI Handle Quota (GDIProcessHandleQuota),
and there I also found one for the User Handle Quota (UserProcessHandleQuota).

Path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows
NOTE: This limits are System limits, not process limits. Was not correct (Thanks to Robert Rohde)

So what I first did was doubleing the values from 10000 to 20000.
And what happens was nothing, no effect!

After a research I than found this very helpfull article[^] from Kristan Kenney

He points out that there are maximum acceptable limits for both values:
GDI max=  16384
User max= 18000

If you set the value over the limits the system will not work proper any more.

So I now did set the limits correct and my project worked again.

Now I wanted to find out how close I could come to the limits,
with my project blowing up a little.
I then scanned over all processes and found out,
that my project still crashes when the UserProcessHandles were about 13500 systemwide.

After rereading the Article from Kristan Kenney, I found an additional Registry setting which he also modified.
Path: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems
Key : Windows
This holds a long string with a section called: "SharedSection=1024,3072,512"
He modifies the second value of thees three (on my test PC there were four) to: "SharedSection=1024,8192,512"

I found a little explaination what this value does, at the msdn support[^]
The second SharedSection value (3072) is the size of the desktop heap for each desktop that is associated with the "interactive" window station WinSta0.
User objects like hooks, menus, strings, and windows consume memory in this desktop heap.
It is unlikely that you would ever need to change this second SharedSection value.

After this modification I was no longer facing crashes.

I'm now going over all my UserControls to find out which one can be modified.
Like, not using a PictureBox and painting the Bitmap in the OnPaint method of the UserControl.
Status from today: -1100 UserProcessHandles!

Hope someone can profit from that information!

Please correct me or give additional information.


-- modified at 9:00 Wednesday 19th September, 2007

All the best,

Martin

GeneralRe: Feedback: How to find the number of current window handles Pin
ramdil19-Sep-07 0:33
ramdil19-Sep-07 0:33 
GeneralRe: Feedback: How to find the number of current window handles Pin
Martin#19-Sep-07 2:16
Martin#19-Sep-07 2:16 
GeneralRe: Feedback: How to find the number of current window handles Pin
Robert Rohde19-Sep-07 2:53
Robert Rohde19-Sep-07 2:53 
GeneralRe: Feedback: How to find the number of current window handles Pin
Martin#19-Sep-07 3:04
Martin#19-Sep-07 3:04 
GeneralRe: Feedback: How to find the number of current window handles Pin
Dave Kreskowiak19-Sep-07 5:28
mveDave Kreskowiak19-Sep-07 5:28 
GeneralRe: Feedback: How to find the number of current window handles Pin
Martin#19-Sep-07 8:17
Martin#19-Sep-07 8:17 
GeneralRe: Feedback: How to find the number of current window handles Pin
Dave Kreskowiak19-Sep-07 12:04
mveDave Kreskowiak19-Sep-07 12:04 
GeneralRe: Feedback: How to find the number of current window handles Pin
Martin#19-Sep-07 19:33
Martin#19-Sep-07 19:33 
GeneralRe: Feedback: How to find the number of current window handles Pin
Dave Kreskowiak20-Sep-07 1:59
mveDave Kreskowiak20-Sep-07 1:59 
GeneralRe: Feedback: How to find the number of current window handles Pin
Martin#20-Sep-07 2:48
Martin#20-Sep-07 2:48 
GeneralRe: Feedback: How to find the number of current window handles Pin
Dave Kreskowiak20-Sep-07 12:35
mveDave Kreskowiak20-Sep-07 12:35 
GeneralRe: Feedback: How to find the number of current window handles Pin
mav.northwind19-Sep-07 19:07
mav.northwind19-Sep-07 19:07 
GeneralRe: Feedback: How to find the number of current window handles Pin
Martin#19-Sep-07 19:35
Martin#19-Sep-07 19:35 
QuestionRemove One Row from DataGridView [modified] Pin
M Riaz Bashir18-Sep-07 21:15
M Riaz Bashir18-Sep-07 21:15 
AnswerRe: Remove One Row from DataGridView Pin
sri_ashutosh18-Sep-07 21:53
sri_ashutosh18-Sep-07 21:53 
AnswerRe: Remove One Row from DataGridView Pin
rohitsrivastava19-Sep-07 0:00
rohitsrivastava19-Sep-07 0:00 
QuestionLive Video Transmission Pin
DeepOceans18-Sep-07 20:41
DeepOceans18-Sep-07 20:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.