apps opening a given extension

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.

No plugins, please. Thanks.

Thank you, Jason, for pointing me at the relevant declare (which I’m afraid I cant ‘translate’ into Xojo code. Happy smily).

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.

Have a look at my example project App Directories.
If you’re downloading the example, you should see “AppURLs”, which lets you select a File. It then locates all suitable Applications, depending on the LSRolesMask you specify.

Note: For this example using LSCopyApplicationURLsForURL you need to specify an existing File… not just an extension.

@Carlo Rubini: Please re-download the example project :wink:
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 :wink:

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.

dim myUrl as CFURL = CFURL(“”)//mailto,http etc.
dim f() as FolderItem = GetAppURLsForURL(myUrl)

where the ‘GetAppURLsForURL’ function returns a list of browsers (from the LSCopyApplicationURLsForURL declares).

BTW: macOSLibrary is still required to execute “dim myUrl as CFURL = CFURL(“”)”.

Thanks again for all the advices. Really appreciated.

Good to hear that the example is working as expected :wink:

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[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.

Excellent. Thank you.