[英]How to find Bundle Identifier from known PID?
I have the pid (process identifier) of an arbitrary running process. 我有任意运行进程的pid(进程标识符)。 How can I find the bundle identifier (if any) of the associated application?
如何找到相关应用程序的软件包标识符(如果有)?
我找到了一个仅适用于10.6的答案:
[[NSRunningApplication runningApplicationWithProcessIdentifier:pid] bundleIdentifier]
Here's a way that works in 10.2 and later: First call GetProcessForPID
to turn the pid into a ProcessSerialNumber
. 这是一种适用于10.2及更高版本的方法:首先调用
GetProcessForPID
将pid转换为ProcessSerialNumber
。 Then call ProcessInformationCopyDictionary
to get the bundle ID. 然后调用
ProcessInformationCopyDictionary
以获取包ID。 (Added: these functions are deprecated in OS 10.9. I don't know if they still exist in the 10.10 SDK.) (补充:OS 10.9中不推荐使用这些功能。我不知道它们是否仍存在于10.10 SDK中。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.