3

I have a process foo.exe that creates a process bar.exe with the CreateProcess function. I want (in foo.exe) to enumerate the controls of a window created in bar.exe and for that I (assume that I) need the window HWND.

I know all the window classes in bar.exe, and that bar.exe only creates one window for each class at a time, so I can use the class names to find the window I want.

But what function should I use to enumerate the windows in another process? I'm looking for something that take a process handle or PID (both returned by the CreateProcess function) and an EnumProc callback procedure. Should I find bar.exe's thread ID (it is a single-threaded application) and use that with the EnumThreadWindows function?

1 Answer 1

6
  1. Call EnumWindows to enumerate the top level windows.
  2. Pass each top level window handle to GetWindowThreadProcessId to find out which process ID it is associated with.
  3. When you find a top level window that matches your process ID, check that the window is the main window of the app, presumably by checking its class name.
  4. Finally, call EnumChildWindows on that main window to enumerate all children of that main window.
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.