'FindWindow Usage 
findwindow(ClassName as String,WindowText as String) as LongClassName为类名,WindowText一般为要搜索的窗体的标题文本。都可以传递"vbNullString"来忽略某个值的制定。返回值为找到的窗口的句柄例如:
ret=findwindow(vbNullString,"MSN")其他两个我没用过

解决方案 »

  1.   

    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long寻找窗口列表中第一个符合指定条件的顶级窗口(在vb里使用:FindWindow最常见的一个用途是获得ThunderRTMain类的隐藏窗口的句柄;该类是所有运行中vb执行程序的一部分。获得句柄后,可用api函数GetWindowText取得这个窗口的名称;该名也是应用程序的标题)
    Long,找到窗口的句柄。如未找到相符窗口,则返回零。会设置GetLastErrorlpClassName ----  String,指向包含了窗口类名的空中止(C语言)字串的指针;或设为零,表示接收任何类  lpWindowName ---  String,指向包含了窗口文本(或标签)的空中止(C语言)字串的指针;或设为零,表示接收任何窗口标题很少要求同时按类与窗口名搜索。为向自己不准备参数传递一个零,最简便的办法是传递vbNullString常数
      示例
      Dim hw& , cnt&
      Dim rttitle As String * 256
      hw&  = FindWindow("ThunderRT5Main", vbNullString) ' ThunderRTMain under VB4
      cnt = GetWindowText(hw& , rttitle, 255)
      MsgBox Left$(rttitle, cnt), 0, "RTMain title"Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long在窗口列表中寻找与指定条件相符的第一个子窗口
    Long,找到的窗口的句柄。如未找到相符窗口,则返回零。会设置GetLastErrorhWnd1 ----------  Long,在其中查找子的父窗口。如设为零,表示使用桌面窗口(通常说的顶级窗口都被认为是桌面的子窗口,所以也会对它们进行查找)  hWnd2 ----------  Long,从这个窗口后开始查找。这样便可利用对FindWindowEx的多次调用找到符合条件的所有子窗口。如设为零,表示从第一个子窗口开始搜索  lpsz1 ----------  String,欲搜索的类名。零表示忽略  lpsz2 ----------  String,欲搜索的标题名。零表示忽略
    Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long枚举窗口列表中的所有父窗口(顶级和被所有窗口)
    Long,非零表示成功,零表示失败lpEnumFunc -----  Long,指向为每个子窗口都调用的一个函数的指针。用AddressOf运算符获得函数在标准模式下的地址  lParam ---------  Long,在枚举期间,传递给dwcbkd32.ocx定制控件之EnumWindows事件的值。这个值的含义是由程序员规定的我的理解——在随vb5同时提供的api32.txt文件中,找不到这个函数
    EnumChildWindows VB声明 
    Declare Function EnumChildWindows Lib "user32" Alias "EnumChildWindows" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long 
    说明 
    为指定的父窗口枚举子窗口 
    返回值 
    Long,非零表示成功,零表示失败 
    参数表 
    参数 类型及说明 
    hWndParent Long,欲枚举子窗口的父窗口的句柄 
    lpEnumFunc Long,为每个子窗口调用的函数的指针。用AddressOf运算符获得函数在一个标准模块中的地址 
    lParam Long,在枚举期间,传递给dwcbkd32.ocx定制控件之EnumWindows事件的值。这个值的含义是由程序员规定的。(原文:Value that is passed to the EnumWindows event of the dwcbkd32.ocx custom control during enumeration. The meaning of this value is defined by the programmer.) 
    注解 
    在vb4下要求dwcbkd32.ocx定制控件。子窗口下属的子窗口也可由这个函数枚举
     
    'EnumWindows
    'Add this code to a form
    Private Sub Form_Load()
        'KPD-Team 2000
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        'Set the form's graphics mode to persistent
        Me.AutoRedraw = True
        'call the Enumwindows-function
        EnumWindows AddressOf EnumWindowsProc, ByVal 0&
    End Sub
    'Add this code to a module
    Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean
    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 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
        Form1.Print Str$(hwnd) + " " + sSave
        'continue enumeration
        EnumWindowsProc = True
    End Function