tags:

views:

145

answers:

2

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?

A: 

Look in the registry. HKCR\SystemFileAssociations find the extension and get the subkeys under OpenWithList.

So for jpg one of my options is photoviewer.dll. Now I look for HKCR\Applications\Photoviewer.dll and fetch the default value of the command key replace %1 with the file name and bang to shell.

csaam
csaam, I think you're answering for the wrong platform.
Rob Napier
+4  A: 

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.

Rob Napier
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