-1

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?

WPFKK
  • 1,419
  • 3
  • 20
  • 42
  • Look at that codeproject article http://www.codeproject.com/Articles/21926/Getting-Process-ID-from-Process-Handle – ColdCat Dec 19 '13 at 16:51

1 Answers1

-1

Have you tried GetProcessesByName() method

foreach (var p in Process.GetProcessesByName("your.exe"))
    {
        p.Kill();
    }
S.N
  • 4,910
  • 5
  • 31
  • 51
  • This would give me multiple processes if there are multiple instances. I dont want that way – WPFKK Dec 18 '13 at 17:55