NO

Author Topic: GetWindowTextA  (Read 1021 times)

Grincheux

  • Guest
GetWindowTextA
« 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

In memory

A GOOD result

Could someone help me please.
« Last Edit: April 27, 2021, 07:48:45 am by Grincheux »

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 580
    • Homepage
Re: GetWindowTextA
« Reply #1 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.
---
Stefan

Proud member of the UltraDefrag Development Team

Grincheux

  • Guest
Re: GetWindowTextA
« Reply #2 on: April 27, 2021, 09:33:51 am »
Ok, but why the other texts are good and not this one? :-\

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 580
    • Homepage
Re: GetWindowTextA
« Reply #3 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?
---
Stefan

Proud member of the UltraDefrag Development Team

Grincheux

  • Guest
Re: GetWindowTextA
« Reply #4 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
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
« Last Edit: April 29, 2021, 01:51:26 pm by Grincheux »