Look into the EnumWindows and EnumChildWindows functions.