Is there a way of detecting whether a url handler exists for a particular protocol?

On macOS and Windows, is there anything in either Xojo or MBS plugins that can tell me whether an app has been configured to handle a particular URL protocol? I don’t need to know which app, just whether anything will handle a particular type of URL.

It’s certainly possible on macOS:

Which means it’s almost certain that MBS has a command.

Thanks, Greg! Yes, something like that would work well, and if there’s an equivalent on Windows then even better.

@Christian_Schmitz Do you have anything that covers this?

Maybe this one?

LaunchServicesAllHandlersForURLSchemeMBS(URLScheme as string) as LaunchServicesStringListMBS

For Windows:

Private Function GetRegisteredURLProtocols() As Dictionary

  // Walking the Windows registry in Xojo seems very costly
  // it takes many seconds to read all classes
  // Be patient while selecting and caching the list of handlers
  Var registeredURLProtocols As New Dictionary
  Var reg As New RegistryItem("HKEY_CLASSES_ROOT", False)
  Var curItem As Integer = 0
      Var inspect As RegistryItem = reg.Item(curItem)
        Var isURLProtocol As Variant = inspect.Value("URL Protocol")
        If isURLProtocol<>Nil then 
          var name As String = inspect.Path.Middle(18) // Remove "HKEY_CLASSES_ROOT\"
      Catch RegistryAccessErrorException // Doesn't exist
    Catch RegistryAccessErrorException // End of list
    curItem = curItem + 1
  Return registeredURLProtocols
End Function
1 Like

Thanks to both @Christian_Schmitz and @Rick_A for the helpful answers!

1 Like