how to get the process name from the PID in C++? [duplicate]
Possi开发者_如何学Cble Duplicate:
How to get Process Name in C++
I am looking for a way to to get the process name from the PID?
I need to translate process id (PID) to process name
any idea?
it depends on the used platform like Yahia mentioned in his comment.
on linux: you can get the command-line by reading that file: /proc/[PID]/cmdline
on windows: I've found this: get process name from process id (win32)
On Windows you can open the process using OpenProcess in order to get a handle to the process. After that you can get the process name with GetProcessImageFileName and close the handle (CloseHandle).
精彩评论