Urgent: How to iterate all windows belonging to a particular process in C#

  • Thread starter Thread starter Vinay
  • Start date Start date
V

Vinay

Hi,
I want to find all the windows created by a particular
process object and close them. Process class only
returns handle to Mainwindow and not other windows.
Furthermore closing mainwindow does not close all other
windows.

Can someone give pointers?
TIA,
Vinay
 
Win32 API:
EnumWindows, EnumChildWindoms, GetWindowThreadProcessId

Brad Williams
 
Thanks Brad.

Is there any functionality available in C#? I do not want
to use Interop

Vinay
 
Vinay,

If these are mdi children, I believe all you will have to do is to loop like
so:

foreach( Form f in this.MdiChildren )
{
IWinCommands iChild = (IWinCommands)f;
iChild.Save();
}



Hope this helps.
 
Ussually it is achieved creating and mantaining a "Forms Collection" in some
shared Collection-Derived variable.
When each of your forms is loaded, you should add code to register itself in
the forms collection.

Good luck
 
Back
Top