vb如何检测多个窗口的句柄
大家都知道,这句hwnd=FindWindow(vbNullString,"窗口标题")只能检测到一个窗口句柄,我多开了好几个窗口,它也还只是获得固定的那一个窗口句柄!直...
大家都知道,这句hwnd = FindWindow(vbNullString, "窗口标题")只能检测到一个窗口句柄,我多开了好几个窗口,它也还只是获得固定的那一个窗口句柄!直是没办法,不知道有没有更好的办法解决这个问题呢?就是说我可以对这个相同的窗口标题的窗口句柄一一读取出来!不知道各位老师有更好的办法吗?知道的最好给源码学习为谢!
小fisher先生,你真是个VB高手,源码也相当有用!如果是你自己写的我真是爱死你了!有许多人回答回题也是从别处搜来的,东拉西扯根本运行不了!叹哪··· 展开
小fisher先生,你真是个VB高手,源码也相当有用!如果是你自己写的我真是爱死你了!有许多人回答回题也是从别处搜来的,东拉西扯根本运行不了!叹哪··· 展开
1个回答
展开全部
Private 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
Private Sub Form_Load()
Dim i As Integer
Dim hwndNext As Long
Dim hwnd() As Long
i = 0
hwndNext = FindWindowEx(0, 0, vbNullString, "窗口标题")
Do While hwndNext <> 0
ReDim Preserve hwnd(i) As Long
hwnd(i) = hwndNext
i = i + 1
hwndNext = FindWindowEx(0, hwnd(i - 1), vbNullString, "窗口标题")
Loop
If i <> 0 Then
For i = 0 To UBound(hwnd)
Debug.Print hwnd(i)
Next
Else
Msgbox "未找到相应标题名的窗口"
End If
End Sub
Private Sub Form_Load()
Dim i As Integer
Dim hwndNext As Long
Dim hwnd() As Long
i = 0
hwndNext = FindWindowEx(0, 0, vbNullString, "窗口标题")
Do While hwndNext <> 0
ReDim Preserve hwnd(i) As Long
hwnd(i) = hwndNext
i = i + 1
hwndNext = FindWindowEx(0, hwnd(i - 1), vbNullString, "窗口标题")
Loop
If i <> 0 Then
For i = 0 To UBound(hwnd)
Debug.Print hwnd(i)
Next
Else
Msgbox "未找到相应标题名的窗口"
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询