Christian Kirchhoff
Christian Kirchhoff

Reputation: 9

Delphi 6 Exe on Vista: Problems with GetWindowText

I have an exe file compiled with Delphi 6 under Windows XP that uses a combination of EnumWindows and GetWindowText to find a window (not belonging to the exe itself) with a specific title.

The behaviour is as expected under Windows XP. On Vista computers however, it doesn't seem to work.

As the mentioned Delphi version doesn't run on Vista, I cannot change and test this directly.

However, I will try to create a modified exe on the XP computer that outputs some additional data and copy it to the Vista computer.

I would just like to ask whether anybody has any information whether there are specific problems known with exe files compiled with Delphi 6 running on Vista regarding EnumWindows/GetWindowText.

The exe uses EnumWindows and GetWindowText to find the handle of a certain window in order to then parse the title of that window in a timer event. The window title is the application name plus the name of the file opened in that application (if any file is opened). The Delphi exe analyses/uses this file name, does something with it and behaves in a certain way.

On Vista the expected behaviour does not appear, thus I presume that the window handle is not found cause GetWindowText does somehow not return the text. Another reason of course could be that EnumWindows does not work properly and the window handle of the window that the exe is looking for is never send to the EnumWindowsProc.

Upvotes: 0

Views: 593

Answers (1)

David Heffernan
David Heffernan

Reputation: 613382

Assuming that there has been no change in window title from XP to Vista, there's not much that can go wrong here. I'd hazard a guess that the problem is due to UIPI. This is part of the security enhancements of Vista and it means that processes can only send messages to other processes that have equal or lower integrity level. Is this other process running elevated?

Other than that your best bet is to run this under the debugger. Delphi 6 most certainly does run on Vista. It was written before UAC and so doesn't get on well with having no rights to write to its install directory. So, install it to somewhere in your user profile or C:\Delphi6 – basically anywhere that standard users have write access.

Finally, don't fall into the trap of running Delphi elevated. This will confound the UIPI issue if indeed that is an issue here.

Good luck!

Upvotes: 4

Related Questions