c++ - SendMessage WM_GETTEXT error -


I am trying to create a program that will name the window of any other program. For this, I want to use the SendMessage () function with the WM_GETTEXT message. I know that I am probably doing a lot of things wrong, so I have the code used here:

  string text; SendMessage (windowhandle, WM_GETTEX, size (text), larampam (text));  

I'm sure ... I have a lot of things wrong: LPARAM (text) is probably wrong since MSDN, it says that this parameter is: Text buffer To an indicator

The problem is ... I do not know what the buffer is and how to declare it ... and how to change it in a string variable with the name of the window inside.

I found the error:

  Error: type 'std :: string {aka std :: basic_string & lt; Char & gt;} from 'Invalid Cast' LPA {aka long int} ' 

Send a message to the line with the error. So my questions are:

What am I doing wrong? What is a buffer? How do I declare buffer? How do I convert that buffer to a text file? If someone can show me my code which I want ... which is probably the best answer I can ask!

The Win32 API is a API, you can not use the C ++ string with it. You need to use a char buffer instead:

  Four lessons [256]; LRESULT result = SendMessage (window handles, WM_GETTEXT, size (text), LPARAM (text));  

In addition to size (text) when the text of a string does not do that you want sizeof Uses a number of bytes, which is not the number of characters in buffer for string , because string dynamically allocates its buffer.

Finally, casting a string to a LPARAM , which is an integer, does not make any sense. In general there is no way to convert the C ++ object to an integer.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -