This code will enumerate all windows on the desktop including child windows, and children of children. There are several other entries here on VBC that perform a similar task, but they add functionality and interfaces that I didn't need... And so this is a more straightforward barebones approach; lighter & cleaner without worrying about treeviews or complicated code- A few API declarations, about a dozen lines of code and you're good to go.
Assumes
Just paste the code into a .bas module and call the EnumerateAllWindows function. In the EnumerateChildren function there is a place where you can do whatever you need to do with each window handle (right now the function prints to the immediate window for demo purposes).
API Declarations'API Declarations
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Const GW_CHILD = 5
Private Const GW_HWNDFIRST = 0
Private Const GW_HWNDNEXT = 2