gpt4 book ai didi

objective-c - 以编程方式获取有关 mac OS X 应用程序的信息

转载 作者:行者123 更新时间:2023-12-03 16:40:42 25 4
gpt4 key购买 nike

我正在寻找 cocoa 框架,它获取每个应用程序的以下信息:供应商名称、版本和完整的应用程序名称。

或者,我可以使用包含此信息的文件...我尝试在/Application/(name).app/... 中搜索它,但我无法在特定位置找到它对于所有应用程序都相同。

最佳答案

它应该在 info.plist 中下CFBundleName

如果您进入 <application>/contents/info.plist你会在那里找到它

来自  documentation :

CFBundleName (String - iOS, OS X) identifies the short name of the bundle. This name should be less than 16 characters long and be suitable for displaying in the menu bar and the app’s Info window. You can include this key in the InfoPlist.strings file of an appropriate .lproj subdirectory to provide localized values for it. If you localize this key, you should also include the key CFBundleDisplayName.

以下是从所选应用程序的 Info.plist 获取版本的示例代码:

string GetAppVersion(string app)
{
NSString *vlcFilePath = [NSString stringWithCString:app.c_str()];
NSDictionary* infoDict = [[NSBundle bundleWithPath:vlcFilePath] infoDictionary];
NSString* version = [infoDict objectForKey:@"CFBundleVersion"];
}
...
...
GetAppVersion("/Applications/Notes.app").c_str());

关于objective-c - 以编程方式获取有关 mac OS X 应用程序的信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31773076/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com