开发者

how to get the process name from the PID in C++? [duplicate]

开发者 https://www.devze.com 2023-04-13 03:33 出处:网络
This question already has answers here: Closed 11 years ago. Possi开发者_如何学Cble Duplicate: How to get Process Name in C++
This question already has answers here: Closed 11 years ago.

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消