Option Explicit Public Declare Function EnumWindows Lib "user32" _ (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long Public Declare Function EnumWindows1 Lib "user32" Alias "EnumWindows" _ (ByVal lpEnumFunc As Long, lParam As Any) As Long Public HandleCol As New Collection Public HandleCol1 As New Collection Public Function EnumWindowsProc(ByVal HandleW As Long, _ ByVal lParam As Long) As Long HandleCol.Add HandleW EnumWindowsProc = 1 End Function Public Function EnumWindowsProc1(ByVal HandleW As Long, _ lParam As Collection) As Long lParam.Add HandleW EnumWindowsProc1 = 1 End Function Public Sub GetHandles() Dim item As Variant Dim Res As Long Res = EnumWindows(AddressOf EnumWindowsProc, 0&) Debug.Print "Number of windows - ", HandleCol.Count Debug.Print "Their handles: " Res = 0 For Each item In HandleCol Debug.Print item Res = Res + 1 If Res > 10 Then Exit For Next item End Sub Public Sub GetHandles1() Dim item As Variant Dim Res As Long Res = EnumWindows1(AddressOf EnumWindowsProc1, HandleCol1) Debug.Print "Number of windows - ", HandleCol1.Count Debug.Print "Their handles: " Res = 0 For Each item In HandleCol1 Debug.Print item Res = Res + 1 If Res > 10 Then Exit For Next item End Sub |
Пример 6.10. |
Закрыть окно |