MSDN mentions the following remark for the GetWindow() function.
The
EnumChildWindowsfunction is more reliable than callingGetWindowin a loop. An application that callsGetWindowto perform this task risks being caught in an infinite loop or referencing a handle to a window that has been destroyed.
Using EnumChildWindows works just fine when only interested in listing all windows. However, what if you need the additional z-order functionality which GetWindow provides? I can't find all windows ordered by z-order using EnumChildWindows.
Does this mean there is no 'safe' way to do so?