vb.net遍历查找标题,一运行就出错退出,不知道原因

weixin_44558368 2019-02-26 04:47:03
Dim lngDeskTopHandle As Integer
Dim strName As String = Space(255)
Dim a As Integer
Dim n As Integer
Dim hw7 As Integer
lngDeskTopHandle = GetDesktopWindow() 'Ok
hw7 = GetWindow(lngDeskTopHandle, GW_CHILD)
n = 0
Do While hw7 <> 0
n = n + 1
GetWindowText(hw7, strName, 255)
hw7 = GetWindow(hw7, GW_HWNDNEXT)
Debug.Print("n=" & n & " " & "hw7=" & Hex(hw7))
On Error Resume Next
If Microsoft.VisualBasic.Left(strName, 1) <> "" Then
If InStr(strName, "光纤") Then
a = FindWindow(vbNullString, strName) '此处a即所需句柄,您可以在此处中断并获取该句柄,或将句柄数据写入数组以获取所有包含"xxx"的窗口句柄
End If
End If
Loop
...全文
20 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

7,765

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧