Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_GETTEXT = &HD '取字符串
Private Const WM_GETTEXTLENGTH = &HE '取字符串长度
Public Function 获取文本() As String
On Error GoTo 出错处理:
Dim a() As Byte
Dim b As Long
Dim JB As Long
JB = 句柄
b = SendMessage(JB, WM_GETTEXTLENGTH, 0, 0)
ReDim a(1 To b) As Byte
Call SendMessage(JB, WM_GETTEXT, ByVal b + 1, a(1))
获取文本 = StrConv(a, vbUnicode)
Exit Function
出错处理:
获取文本 = ""
End Function