2013-10-17 63 views
1

我需要檢查Mac電腦上是否安裝了多個版本的應用程序。如何檢查Mac機器上安裝的應用程序的多個版本

我需要檢查是否安裝了Mac電腦上的谷歌瀏覽器的多個版本,並

打開與谷歌瀏覽器的最新版本的URL。

+0

使用啓動服務/ CFBundle通過捆綁ID進行搜索。 cf http://stackoverflow.com/a/1583143/210171&http://stackoverflow.com/a/10063710/210171 – nielsbot

回答

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 
相關問題