views:

179

answers:

1

The user32.dll provides functions to get the process id from a process executable name, and I can also obtain the active or foreground window that the user is working.

Can I determine what windows the targeted process has opened? Otherwise, can I find out what details about the process that opened the foreground/active window?

My code needs to run only when another specific process is running and the user is actively using that window, while that window is the top-most window on the desktop.

+1  A: 

I think you want to use GetWindowThreadProcessId or possibly EnumThreadWindows

John Knoeller
Combined with GetForegroundWindow, this should do it.
MarkJ