Copies the text of the specified window's title bar (if it has one) into a buffer. If the specified window is a control, the text of the control is copied. However, GetWindowText cannot retrieve the text of a control in another application.
Note the last sentence.
But the same entry does go on to remark
To retrieve the text of a control in another process, send a WM_GETTEXT message directly instead of calling GetWindowText.
Yes, you must send the WM_GETTEXT message. As I recall, you need to allocate the buffer in the external application using VirtualAllocEx(), then use ReadProcessMemory() to import the result into your own address space.
@webJose - I think the system handles the memory marshalling for you in the case of WM_GETTEXT and other standard messages.
From MSDN entry for SendMessage (ok, the logic is reversed, but...)
The system only does marshalling for system messages (those in the range 0 to (WM_USER-1)). To send other messages (those >= WM_USER) to another process, you must do custom marshalling.
Then you'll have to be more cunning with the searching.
Either search by name, or search for the n'th edit box (FindWindowEx's 2nd param is hwndChildAfter -- the search begins with the next child window in the Z order.)