문제

Hi I have a simple requirement to kill a process or get a process using the Handle.

I tried getting the process using handle but i don't see any good API that does that. Alternately I tried getting all active processes by Process.GetProcesses() looped through each process to see if they match the handle but it throws exception when trying to access some handles. So I guess that's not the best way.

How can i achieve this?

도움이 되었습니까?

해결책

Have you tried GetProcessesByName() method

foreach (var p in Process.GetProcessesByName("your.exe"))
    {
        p.Kill();
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top