GetWindowTextA

Started by Grincheux, April 27, 2021, 07:25:37 AM

Previous topic - Next topic

Grincheux

Problem with this function. Sometimes it returns a good result and sometimes it returns a wrong result!
Using WM_GETTEXT does not give a better result!

                     mov      rcx,_hWnd
                     lea      rdx,_Infos.szWindowText
                     mov      r8d,MAX_PATH
                     call   GetWindowTextA

The bad result

In memory

A GOOD result

Could someone help me please.

Stefan Pendl

Are you sure that you have a ANSI window created and not a Unicode one?
For Unicode text you would need to use GetWindowTextW, which would also support retrieving ANSI text.
You can then use various functions to convert from Unicode to ANSI text for further processing.
---
Stefan

Proud member of the UltraDefrag Development Team

Grincheux

Ok, but why the other texts are good and not this one? :-\

Stefan Pendl

Is the GDI+ window really the bad result? Memory and property listing seem to display the same things.
What are you trying to do?
What result are you expecting?
---
Stefan

Proud member of the UltraDefrag Development Team

Grincheux

#4
I want to get all the windows in the system with their class, title...
Launch the program an you see.
I have just read that GetWindowText doest not alway returns the good result.
https://docs.microsoft.com/en-us/archive/msdn-magazine/2001/august/c-q-a-getting-the-text-of-a-window-in-another-application;-making-backspace-work-in-the-explorer-bar
read that too : https://ptgmedia.pearsoncmg.com/images/9780321440303/samplechapter/chen_ch03.pdf
I have changed and use GetWindowTextW now...

Thank You for your help