4

Is it possible to get a list of applications installed on the users computer that could be used to open a file (in my case an image), similar to the list shown through the Finder's "Open With..." menu?

Quinn Taylor
  • 44,553
  • 16
  • 113
  • 131
Harry Jordan
  • 305
  • 2
  • 8

1 Answers1

7

Are you looking for a programatic or scripting solution? Programatically, look at Launch Services (LSCopyAllRoleHandlersForContentType() for instance). For scripting, you probably want lsregister which is buried down in

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Support

Don't let its location in the docs fool you. It in the Carbon docs, but it's actually CoreServices, which is not deprecated.

Alex Martelli
  • 854,459
  • 170
  • 1,222
  • 1,395
Rob Napier
  • 286,113
  • 34
  • 456
  • 610
  • 1
    I've found LSCopyApplicationURLsForURL() to be more useful, because it includes Carbon applications as well as Cocoa. When inspecting a jpeg file LSCopyAllRoleHandlersForContentType() was returning about 7 app identifiers, whereas LSCopyApplicationURLsForURL() found 27. – Harry Jordan Jun 27 '09 at 11:40