Here is how to get all the window handles:

Code:
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpstring As String, ByVal cch As Long) As Long

Function GetCaption(hwnd)
hwndLength% = GetWindowTextLength(hwnd)
hwndTitle$ = String$(hwndLength%, 0)
a% = GetWindowText(hwnd, hwndTitle$, (hwndLength% + 1))
GetCaption = hwndTitle$
End Function

Private Sub Command1_Click()
For i = 1 To 10000
X = GetCaption(i)
List1.AddItem X
Next i
End Sub
Here is how to get a list of running files: App List and Kill

Here is the link to an Api Spy.

Or make your own: Windows Spy