Private Declare Function EnumThreadWindows Lib "user32" Alias "EnumThreadWindows" (ByVal dwThreadId As Long, ByVal lpfn As Long, ByVal lParam As Long) As Long
http://ygyuan.go.163.com/
http://ygyuan.3322.net/

解决方案 »

  1.   

    GetWindow VB声明 
    Declare Function GetWindow Lib "user32" Alias "GetWindow" (ByVal hwnd As Long, ByVal wCmd As Long) As Long 
    说明 
    获得一个窗口的句柄,该窗口与某源窗口有特定的关系 
    返回值 
    Long,由wCmd决定的一个窗口的句柄。如没有找到相符窗口,或者遇到错误,则返回零值。会设置GetLastError 
    参数表 
    参数 类型及说明 
    hwnd Long,源窗口 
    wCmd Long,指定结果窗口与源窗口的关系,它们建立在下述常数基础上: 
    GW_CHILD 寻找源窗口的第一个子窗口 
    GW_HWNDFIRST 为一个源子窗口寻找第一个兄弟(同级)窗口,或寻找第一个顶级窗口 
    GW_HWNDLAST 为一个源子窗口寻找最后一个兄弟(同级)窗口,或寻找最后一个顶级窗口 
    GW_HWNDNEXT 为源窗口寻找下一个兄弟窗口 
    GW_HWNDPREV 为源窗口寻找前一个兄弟窗口 
    GW_OWNER 寻找窗口的所有者 
    注解 
    兄弟或同级是指在整个分级结构中位于同一级别的窗口。如某个窗口有五个子窗口,那五个窗口就是兄弟窗口。尽管GetWindow可用于枚举窗口,但倘若要在枚举过程中重新定位、创建和清除窗口,那么EnumWindows和EnumChildWindows更为可靠
      

  2.   

    Declare Function EnumChildWindows Lib "user32" Alias "EnumChildWindows" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long'in a form
    Private Sub Form_Load()
        'KPD-Team 2000
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        Me.AutoRedraw = True
        EnumChildWindows GetDesktopWindow, AddressOf EnumChildProc, ByVal 0&
    End Sub
    'in a module
    Declare Function GetDesktopWindow Lib "user32" () As Long
    Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
    Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
    Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
        Dim sSave As String
        'Get the windowtext length
        sSave = Space$(GetWindowTextLength(hwnd) + 1)
        'get the window text
        GetWindowText hwnd, sSave, Len(sSave)
        'remove the last Chr$(0)
        sSave = Left$(sSave, Len(sSave) - 1)
        If sSave <> "" Then Form1.Print sSave
        'continue enumeration
        EnumChildProc = 1
    End Function