Get Application’s Window Handles

You could do what Process.MainWindowHandle appears to do: use P/Invoke to call the EnumWindows function, which invokes a callback method for every top-level window in the system.

In your callback, call GetWindowThreadProcessId, and compare the window’s process id with Process.Id; if the process ids match, add the window handle to a list.

Leave a Comment