The Win32 API is a C api, you can't use a C++ string with it. You need to use a char
buffer instead:
char text[256];
LRESULT result = SendMessage(windowHandle, WM_GETTEXT, sizeof(text), LPARAM(text));
Also sizeof(text)
when text
of a string doesn't do what you want. sizeof
gives the number of bytes a uses, which for a string
is not the number of characters in the buffer since a string
dynamically allocates its buffer.
Finally casting a string
to an LPARAM
, that is an integer doesn't make any sense. In general there is no way to convert a C++ object to an integer.