试试用API Findwindow 再用向它发送WM_CLOSE消息

解决方案 »

  1.   

    Private Sub Form_Load()
    Dim a As Long, b As Long, c As Long, d As String, e As String, f As Long
    Dim istack As Long
    istack = WS_VISIBLE Or WS_BORDER
    a = GetWindow(Me.hwnd, GW_HWNDFIRST)
    b = GetWindowTextLength(Me.hwnd) + 1
    d = Space$(b)
    c = GetWindowText(Me.hwnd, d, b)
    'List1.AddItem dDo While a
    f = GetWindowLong(a, GWL_STYLE)
          If a <> Me.hwnd And (f And istack) = istack Then
       b = GetWindowTextLength(a) + 1
       d = Space$(b)
       c = GetWindowText(a, d, b)
        If c <> 0 Then
       List1.AddItem d
        End If
       End If
    a = GetWindow(a, GW_HWNDNEXT)
    Loop
    这是判段有窗体的,要判段没窗体的,把那个判断语句去掉,然后sendmessage