Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get process name from pid or handle

Assuming I already have the handle to a window, I can get the PID with GetWindowThreadProcessId. Is there a way I can get the process name without having to get all the processes and try to match my PID?

like image 472
user579674 Avatar asked Jan 27 '11 17:01

user579674


1 Answers

You can use Process.GetProcessById to get Process. Process has a lot of information about the running program. Process.ProcessName gives you the name, Process.MainModule.FileName gives you the name of the executable file.

like image 70
detunized Avatar answered Nov 06 '22 23:11

detunized