Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi - How to kill a process by knowing its path?

Until now I was using this function to kill a process. But what if I have three processes of the same name and only one of them is the one that I want to kill? If I will do this: KillTask('csrss.exe') then it will kill the system process. I have the path of my process, how can I use this information to kill it?

like image 479
user2225809 Avatar asked Nov 17 '25 17:11

user2225809


1 Answers

Iterate over processes and check the path for each of them, then use the answer from this SO question (use GetModuleFileNameEx):

get the full path from a PID using delphi

If you launched the process then remember the PID or Handle and kill the specific one.

like image 146
Runner Avatar answered Nov 19 '25 09:11

Runner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!