Is there a way of getting the process id of my C++ application?

爱⌒轻易说出口 提交于 2019-12-23 12:16:53

问题


Is there a way of getting the process id of my C++ application? I am using the Carbon framework, but not Cocoa…


回答1:


can you use the getpid() function found in unistd.h ?

osx reference




回答2:


GetProcessPID is what you need. This takes a ProcessSerialNumber, which you can obtain from GetCurrentProcess.




回答3:


Note that you don't actually need to call GetCurrentProcess, you can use the constant kCurrentProcess.

(But getpid is a lot less work if you're not trying to access another process's PID, anyway.)



来源:https://stackoverflow.com/questions/41676/is-there-a-way-of-getting-the-process-id-of-my-c-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!