Hi DraguVaso,
Explorers (window and internet) create only one process. They spawn threads
for each individual GUI. If I'm not mistaken office products work the same
way. Process.MainWindowHandle enumerates all top-level windwos and returns
the first which is created by the given process. So it returns one of the
provess top-level widnows whichever is enumerated first.
I'm pretty sure if there is no managed solution for your problem so you
need to go ahead and use PInvoke.
Probably you have several solutions but I'll give you two of them:
1. Use EnumWindows (as Process.MainWindowHandle does) and filter IE windows
using GetWindowThreadProcessId API
2. Get all process' threads (Process.Threads property) and then call
EnumTreadWindows to narrow down the number of windows to enumerate
--
HTH
Stoitcho Goutsev (100) [C# MVP]
"DraguVaso" <pi**********@hotmail.com> wrote in message
news:OS**************@TK2MSFTNGP12.phx.gbl...
Hi,
I need to do osme handlings with an Internet Explorer Window. The problem
is: when the user has one ore more Internet Explorers opened, this is
(sometimes) indicated in the Task Manager as one process and not 2 or
more. When trying to get all the IE-windowd with the "For Each p In
Process.GetProcessesByName("IEXPLORE")"-function, I only get 1 process
returned, which has as "p.MainWindowTitle" the MainWindowTitle of one of
the open IE-windows.
Like that I'm not able to work with that IE-window I need. Does anybody
how to get arroudn this problem? Is there a way to go directly by the
Windows/Applications and not the Processes?
Thanks,
Pieter