Per il momento, ho trovato e sto provando questa, che sembra promettente:
function GetCurrentActiveProcessPath: String;
var pid : DWORD;
hProcess: THandle;
path : array[0..4095] of Char;
begin
GetWindowThreadProcessId(GetForegroundWindow, pid);
hProcess := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, FALSE, pid);
if hProcess <> 0 then
try
if GetModuleFileNameEx(hProcess, 0, @path[0], Length(path)) = 0 then
RaiseLastOSError;
result := path;
finally
CloseHandle(hProcess);
end
else
RaiseLastOSError;
end;
Ciao, Mario