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
2009-06-27 00:11:12
csaam, I think you're answering for the wrong platform.
Rob Napier
2009-06-27 00:18:19
+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
2009-06-27 00:24:47
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
2009-06-27 11:40:19