Возникла проблема с получением списка открытых окон. Вобщем мне нужно в ListBox вывести весь список открытых окон, но не
список задач, а только тех программ и окон, которые находятся в "панели задач". Как это сделать?
Option Explicit
Private Sub Form_Load()
GetAllWindows
End Sub
Option Explicit
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex 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
Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function IsWindowVisible Lib "user32" (ByVal hWnd As Long) As Long
Private Const GWL_STYLE = -16&
Private Const GWL_EXSTYLE = -20&
Private Const WS_EX_APPWINDOW = &H40000
Private Const WS_NOT_OVERLAPPED = &HC0000000
Private Const WS_BORDER = &H800000
Public Sub GetAllWindows()
EnumWindows AddressOf EnumWindowsProc, 0
End Sub
Private Function EnumWindowsProc(ByVal hWnd As Long, ByVal lParam As Long) As Long
Dim Caption As String * 256
If IsWindowVisible(hWnd) Then
If (GetWindowLong(hWnd, GWL_EXSTYLE) And WS_EX_APPWINDOW) Or _
(((GetWindowLong(hWnd, GWL_STYLE) And WS_NOT_OVERLAPPED) = 0) And _
(GetWindowLong(hWnd, GWL_STYLE) And WS_BORDER)) Then
GetWindowText hWnd, Caption, 256
Form1.List1.AddItem Caption
End If
End If
EnumWindowsProc = 1
End Function
Сейчас этот форум просматривают: Yandex-бот и гости: 2