.NET (C#): Getting child windows when you only have a process handle or PID?

If you don’t mind using the Windows API, you could use EnumWindowsProc, and check each of the handles that that turns up using GetWindowThreadProcessId (to see that it’s in your process), and then maybe IsWindowVisible, GetWindowCaption and GetWindowTextLength to determine which hWnd in your process is the one you want.

Though if you haven’t used those functions before that approach will be a real pain, so hopefully there’s a simpler way.

Leave a Comment