Pelles C forum

Assembly language => Assembly discussions => Topic started by: Grincheux on April 27, 2021, 07:25:37 AM

Title: GetWindowTextA
Post by: Grincheux on April 27, 2021, 07:25:37 AM
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!

Code: [Select]
                     mov      rcx,_hWnd
                     lea      rdx,_Infos.szWindowText
                     mov      r8d,MAX_PATH
                     call   GetWindowTextA
The bad result
(https://www.mediafire.com/convkey/23f7/cczj9shv2y06a3x6g.jpg)
In memory
(https://www.mediafire.com/convkey/e484/ukasf5b41a5zvk46g.jpg)
A GOOD result
(https://www.mediafire.com/convkey/ef02/70l399ni0pngzuj6g.jpg)
Could someone help me please.
Title: Re: GetWindowTextA
Post by: Stefan Pendl on April 27, 2021, 09:20:07 AM
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.
Title: Re: GetWindowTextA
Post by: Grincheux on April 27, 2021, 09:33:51 AM
Ok, but why the other texts are good and not this one? :-\
Title: Re: GetWindowTextA
Post by: Stefan Pendl on April 27, 2021, 10:00:10 AM
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?
Title: Re: GetWindowTextA
Post by: Grincheux on April 27, 2021, 10:21:34 AM
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 (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 (https://ptgmedia.pearsoncmg.com/images/9780321440303/samplechapter/chen_ch03.pdf)
I have changed and use GetWindowTextW now...

Thank You for your help