I am Trying to get Data from another program but the Buffer is not returning any information

this is my Code

Declare Function SendMessage Lib “user32” Alias “SendMessageA” ( hwnd As Integer, wMsg As Integer, wParam As Integer, lParam As Integer) As Integer
Declare Function SendMessageSTRING Lib “user32” Alias “SendMessageA” ( hWnd As Integer, wMsg As Integer, wParam As Integer, lParam As CString ) As Integer
Declare Function FindWindow Lib “user32” Alias “FindWindowA” (ByVal lpClassName As CString, ByVal lpWindowName As CString) As Integer
Declare Function GetWindow Lib “user32” ( hWnd As integer, wCmd As integer ) As integer

Const WM_GETTEXT = &HD
Const GW_CHILD = 5
Const WM_GETTEXTLENGTH = &HE

Dim TextLen As Integer
Dim XY As Integer
Dim Buffer As String
Dim iHwndChild As Integer
Dim iHwnd As Integer

iHwnd= FindWindow(“ThunderRT6MDIForm”,“TheProgram”)
iHwndChild=iHwnd //<— IHwend Pointer is found
iHwndChild = GetWindow(iHwndChild, GW_CHILD) //<— iHwndChild Pointer is found
iHwndChild = GetWindow(iHwndChild, GW_CHILD) //<— iHwndChild Pointer is found
iHwndChild =GetWindow(iHwndChild, GW_CHILD) //<— iHwndChild Pointer is found
Buffer = Spaces(256)
TextLen= SendMessage(iHwndChild, WM_GETTEXTLENGTH, 0, 0) + 1 //<— The Correct Text is returned

XY= SendMessageSTRING (iHwndChild, WM_GETTEXT, TextLen, Buffer) //<— Not working Buffer has no data in it.
MsgBox(Buffer)

On first glance, try using a memoryblock rather than a string for your buffer and pass lParam As ptr.

Thanks Jim. You fixed my problem.

Declare Function SendMessageSTRING Lib "user32" Alias "SendMessageA" ( hWnd As Integer, wMsg As Integer, wParam As Integer, lParam As Ptr) As Integer // // Dim Buffer As Memoryblock