简体   繁体   English

如何从已知的PID中找到Bundle Identifier?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM