vb6 获取窗口标题

[复制链接]
查看11 | 回复2 | 2010-6-25 10:58:58 | 显示全部楼层 |阅读模式
Public Function GetWindowTitle(hWnd As Long) As String

On Error Resume Next

Dim s
As String

l = GetWindowTextLength(hWnd)

s = Space$(l + 1)

GetWindowText hWnd, s, l + 1

GetWindowTitle = Left$(s, l)

Debug.Print 1
End Function
这个是vb6 获取窗口标题的函数 但是取到的有可能 结束会有特殊字符 恶心的很啊



回复

使用道具 举报

千问 | 2010-6-25 10:58:58 | 显示全部楼层
那是一个空字符, 就是 chr(0)
s = Space$(l)
GetWindowText hWnd, s, l
GetWindowTitle = Left$(s, l)这样就行了,没必要 +1
回复

使用道具 举报

千问 | 2010-6-25 10:58:58 | 显示全部楼层
GetWindowTitle = Left$(s, l-1)不就可以了么?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行