1

I need to check if Multiple Versions of an application is installed on a Mac computer.

I need to check if Multiple versions of Google Chrome is installed on a mac computer and

Open an URL with the Latest Version of the Google Chrome.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Dinesh Kaushik
  • 2,917
  • 2
  • 23
  • 36
  • use launch services/CFBundle to search by bundle ID. cf http://stackoverflow.com/a/1583143/210171 & http://stackoverflow.com/a/10063710/210171 – nielsbot Oct 17 '13 at 10:01

1 Answers1

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
Parag Bafna
  • 22,812
  • 8
  • 71
  • 144