'Lance la procédure d'énumération
Sub Test()
EnumWindows AddressOf EnumWindowsProc, ByVal 0&
End Sub
'Enumère les fenêtres dans la session
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
Debug.Print Str$(hwnd) + ' / ' + sSave + ' / ' + sClass(hwnd)
'continue enumeration
EnumWindowsProc = True
End Function
'Donne le nom de la class du handle de la fenêtre
Function sClass(x As Long)
Dim className As String
Dim retValue As Long
className = String$(256, ' ')
retValue = GetClassName(x, className, 255)
sClass = Left$(className, InStr(className, vbNullChar) - 1)
End Function
'Test si un programme est lancé ou non
Function IsAppRunning(x As String) As Boolean
Dim hwnd As Long
IsAppRunning = False
hwnd = FindWindow(x, vbNullString)
If hwnd > 0 Then
IsAppRunning = True
End If
End Function