Listing 1: Enumerating through the full range, then storing items in a container.
#include <windows.h> #include <list> typedef std::list<HWND> HWND_list_t; BOOL CALLBACK ChildWindowProc(HWND hwnd, HWND_list_t &wndlist) { return (wndlist.push_back(hwnd), TRUE); } void main() { HWND_list_t wndlist; if(::EnumChildWindows(0, (WNDENUMPROC)ChildWindowProc, (LPARAM)&wndlist)) { HWND_list_t::const_iterator begin = wndlist.begin(); HWND_list_t::const_iterator end = wndlist.end(); for(; begin != end; ++begin) { fprintf(stdout, "HWND: 0x%08x\n", *begin); } } }