Module1
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 Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Function EnumWindowsProc2(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
Dim S As String
S = String(80, Chr(0)) Call GetWindowText(hwnd, S, 80) S = Left(S, InStr(S, Chr(0)) - 1)
If Len(S) > 0 Then Form1.List1.AddItem S End If
EnumWindowsProc2 = True
End Function
Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean Dim sSave As String, Ret As Long Ret = GetWindowTextLength(hwnd) sSave = Space(Ret) GetWindowText hwnd, sSave, Ret + 1 Form1.List1.AddItem Str$(hwnd) + " " + sSave 'continue enumeration EnumWindowsProc = True End Function
Form1
Private Sub Command1_Click()
List1.Clear EnumWindows AddressOf EnumWindowsProc2, 0& End Sub
Private Sub Command2_Click()
List1.Clear EnumWindows AddressOf EnumWindowsProc, 0&
End Sub
Private Sub Form_Load()
End Sub
|