is there a way to get a list of all the apps that can deal with a given extension?
For instance all the apps that can deal with .doc files, or .html files and so on.
(As the Finder does when, right-clicking a given file, it shows a list of possible apps able to open it).
I know how to get (thu declares) the default app opening a given extension; but in this case I need a list of all apps.
have a look at macoslib. There is already a function “FindAppsForURL” which does use a LSCopyApplicationURLsForURL declare.
I guess it needs a little tweaking for current Xojo version but that should not too hard.
@Carlo Rubini: Please re-download the example project
I’ve modified the example to show how to use the “Mask”, e.g. to get the list for just the two “LSRolesViewer | LSRolesEditor”.
And I’ve added the CFRelease of the returned CFArrayRef. One needs to release that in order not to leak memory
At first my apologies, because, after some tests, I realized that what I was actually looking for was not [quote]a list of all the apps that can deal with a given extension[/quote].
In fact, as @Jürg Otter’s app shows, one rightly gets a list of ALL the apps fit to open a file with a given extension (as the Finder does when right-clicking a file). In my specific case, selecting a html file, I would get my browsers + TextEdit, BBEdit etc. apps.
But what I was specifically looking for was a list of browsers only, and for that the necessary URL would be “http”.
And this can be accomplished by the suggested LSCopyApplicationURLsForURL function, that as @Thomas Eckert pointed out is also available in the MacOSLibrary and with some easy tweaking can be adapted to today’s Xojo needs.
Good to hear that the example is working as expected
That’s a little tweak… I’ve just added it to the example project: App Directories.
You can now both use a FolderItem (and use it’s .URLPath). Or any other URL (as String), e.g. an ordinary Website URL. Or other registered URL Schemes such as feedback://showreport?report_id=58365(which will locate Xojo’s Feedback.app).[quote=476300:@Carlo Rubini]macOSLibrary is still required[/quote]
And if you or someone else doesn’t want to include the whole macOSLibrary, then have another look at the updated example project: App Directories.