我正在尝试查找 Mac 计算机上安装的 Google Chrome 的版本号。 ?
如何找到版本号。
请用一些片段回答。
最佳答案
以同样的方式获取任何其他应用程序的版本:Create an NSBundle object for that application's application bundle ,然后 ask it for its value for Info.plist 键 kCFBundleVersionKey
。该键的值是包含应用程序版本的 NSString 或 NSNumber。
要创建 NSBundle 对象,您需要找到 Chrome 的安装位置:
- 如果 Chrome 正在运行,则有一个 NSRunningApplication。使用the
runningApplicationsWithBundleIdentifier:
method ,然后,从每个正在运行的应用程序中获取其bundleURL
并从中创建一个 NSBundle。您可能想要找到最大的版本号(最新运行的版本)。 - 如果 Chrome 未运行,则
runningApplicationsWithBundleIdentifier:
将返回一个空数组,您应该继续尝试在磁盘上查找该包。询问the shared NSWorkspace对于 absolute path to a bundle with Chrome's bundle identifier ,然后 create an NSBundle with that .
关于macos - 如何检查 Mac 系统上安装的 Google Chrome 版本号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19381295/