EnumWindow



'Getting all windows

Public Const MAX_PATH = 260
Public Const SW_HIDE = 0
Public Const SW_SHOW = 5
Public Const SW_MAXIMIZE = 3
Public Const SW_MINIMIZE = 6
Public Const SW_NORMAL = 1
Public Const SW_RESTORE = 9
Public Const WM_CLOSE = &H10
Public Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Integer, _
ByVal lParam As Long) As Long
Public Declare Function ShowWindow Lib "user32" _
(ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Public Declare Function IsWindowVisible Lib "user32" _
(ByVal hwnd As Long) As Long
Public Declare Function EnumWindows _
Lib "user32" (ByVal lpEnumFunc As Long, _
ByVal lParam As Long) As Long
Public Declare Function GetClassName Lib "user32" _
Alias "GetClassNameA" _
(ByVal hwnd As Long, _
ByVal lpClassName As String, _
ByVal nMaxCount 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
EnumWindowProc = 1 'To keep EnumWindows from
'continuing it's loop, have

'your function return 1.

End Function

Public Function EnumWindowProc(ByVal hwnd As Long, _
ByVal lParam As Long) As Long
Dim sTitle As String
Dim sClass As String
Dim sLoc As String
sTitle = Space$(MAX_PATH)
sClass = Space$(MAX_PATH)
sLoc = Space$(MAX_PATH)
'sClass

Call GetClassName(hwnd, sClass, MAX_PATH)
'and sTitle

Call GetWindowText(hwnd, sTitle, MAX_PATH)
'You can place the function in any event

'Call function like this:

Call EnumWindows(AddressOf EnumWindowProc, &H0)

(enumwindow.html)- by Paolo Puglisi - Modifica del 25/3/2019