Private Sub Command1_Click()
EnumWindows AddressOf WndEnumProc, 0
End Sub
'以下代码放在模块文件里
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Function WndEnumProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim strTitle As String
strTitle = Space(80)
GetWindowText hwnd, strTitle, 80
strTitle = Replace(strTitle, Chr(0), " ")
strTitle = Trim(strTitle)
If strTitle <> "" Then
    Form1.List1.AddItem strTitle
End If
WndEnumProc = 1
End Function