我需要检查Mac计算机上是否安装了多个版本的应用程序。
我需要检查Mac计算机上是否安装了多个版本的Google Chrome并且
使用最新版Google Chrome打开网址。
答案 0 :(得分:4)
NSURL *url = [[NSURL alloc] initWithScheme:@"http" host:@"example.host.com" path:@"/example"];
CFArrayRef finds = LSCopyApplicationURLsForURL (
(CFURLRef) url,
kLSRolesAll
) ;// all web applications
for(int i=0;i<CFArrayGetCount(finds);i++)
{
CFURLRef appURL = CFArrayGetValueAtIndex(finds,i);
MDItemRef item = MDItemCreateWithURL(kCFAllocatorDefault, appURL);
CFTypeRef itemVersion = MDItemCopyAttribute(item, kMDItemVersion);// version
NSLog(@"appURL %@ itemVersion %@",appURL,itemVersion);
}
//appURL file://localhost/Applications/Google%20Chrome.app/ itemVersion 30.0.1599.101