I am trying to get the path and filename of the current foreground window application. I am trying to use the following code, but it doesn't work properly. It only gives me the path/filename of my delphi application.
Also, please, an explanation of why this function doesn't work.
WHndPath : array [0..MAX_PATH] of char;
CurrentHWnd : HWND;
CurrentHWnd := GetForegroundWindow;
GetModuleFileName(CurrentHWnd, WHndPath, MAX_PATH);
Result := StrPas(WHndPath);
Any help would be appreciated.