In Delphi XE7, I want to get the path of the program which has the topmost window. This implies to first get the handle of the topmost window:
hwnd := GetForegroundWindow;
The next step implies several different functions which I have found in examples on the Internet. Some of them work reliably with most programs, but they fail with some specific programs
, e.g. DOpus, KeePass: With those specific programs only the filename of the program or nothing is returned.
Does anybody have a reliable method which works with ALL programs?
Currently I am working in Windows 7 x64 SP1