No necesitas la ruta para terminar un proceso, solo Process Id
Código:
// uses TlHelp32;
function GetProcessIdByName(const ExeName: string): Integer;
var PE: TProcessEntry32;
hSS: THandle;
s: string;
begin
Result := 0;
hSS := CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, GetCurrentProcessId);
PE.dwSize := SizeOf(PE);
Process32First(hSS, PE);
repeat
s := PE.szExeFile;
if CompareText(s, ExeName) = 0 then
begin
Result := PE.th32ProcessID;
Break;
end;
until not Process32Next(hSS, PE);
CloseHandle(hSS);
end;
procedure KillProcessById(ProcessId: Integer);
var h: THandle;
begin
h := OpenProcess(PROCESS_TERMINATE, False, ProcessId);
if h = 0 then Exit;
TerminateProcess(h, 0);
CloseHandle(h);
end;
function GetFullExePathById(ProcessId: Integer): string;
var ME: TModuleEntry32;
hSS: THandle;
s: string;
begin
Result := '';
hSS := CreateToolHelp32SnapShot(TH32CS_SNAPMODULE, ProcessId);
ME.dwSize := SizeOf(ME);
Module32First(hSS, ME);
repeat
s := LowerCase(ME.szExePath);
if Pos('.exe', s) <> 0 then
begin
Result := s;
Break;
end;
until not Module32Next(hSS, ME);
CloseHandle(hSS);
end;