All forms in a process

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
Is there an easy way of finding out how many forms a process has created?
Something like .AllForms property?


Thank you,
 
* "=?Utf-8?B?am9obiBzbWl0aA==?= said:
Is there an easy way of finding out how many forms a process has created?
Something like .AllForms property?

Currently, no. You will have to update a counter yourself.
 
There is no managed solution for that or at least I can't find it.

Anyways you can use a little PInvoke.

First use Process class to get reference to the current process. Then from
Threads property you can get collection of all the threads running in the
process. After that using PInvoke you can enumerate all windows in the
threads(EnumThreadWindows API).

But bare in mind the Process.Threads property returns window threads which
are different than .NET thread objects. WindowsThreads coross applicaiton
domain boundaries so, I guess you are going to enumarate even windows which
doesn't belong to the current application domain (.NET application). You
always can do more filtering, though.
 
Back
Top