Function GetHWndText(hWnd As Long) As String
    hLength = SendMessage(hWnd, WM_GETTEXTLENGTH, 0, 0)
    If hLength < 1 Then
        GetHWndText = ""
    Else
        ReDim bArr1(hLength + 1) As Byte, bArr2(hLength - 1) As Byte
        
        RtlMoveMemory bArr1(0), hLength, 2
        SendMessage hWnd, WM_GETTEXT, hLength + 1, bArr1(0)
        RtlMoveMemory bArr2(0), bArr1(0), hLength
        
        GetHWndText = StrConv(bArr2, vbUnicode)
    End If
End Function