How can I pass a URI to a running desktop app

A user can click on a URI (perhaps mailto: or ftp:) in for example a Safari window. Assuming my app is set to be the default app for a given URI type, how can I get that URI passed to my app so it can handle it?

App.OpenDocument

What would that give you for a URI? That event supplies a folderitem.

Command line, perhaps?

dim sh as new shell sh.execute("start http://fontmenu.com") sh.execute("start mailto:tagada@test.com")

Windows: https://blog.xojo.com/2016/08/16/custom-uri-schemes-on-windows/

Mac: http://blog.xojo.com/2016/05/09/let-your-os-x-desktop-app-react-to-custom-uris/

If you have App Wrapper, there’s a help document on how to configure your Mac application and how to support it from within the product.

[quote=382557:@Paul Lefebvre]Windows: https://blog.xojo.com/2016/08/16/custom-uri-schemes-on-windows/

Mac: http://blog.xojo.com/2016/05/09/let-your-os-x-desktop-app-react-to-custom-uris/[/quote]

Well, for macOS that works a treat, both when the app is running, and if it is not. For the Windows equivalent, I have a couple of questions:

  1. It suggests that the registry modifications be done at the install stage rather than at the app’s runtime. Can I do this at runtime instead? If so, and the user doesn’t have admin privs, would it offer to authenticate the user? And if I do it at runtime, is that making a new entry in the registry each time the app runs, or is it replacing the entry from last time I ran the app (I worry about the registry getting bigger and bigger).

  2. The method given seems oriented towards starting the app when it is not running, and then having the app look at the System.CommandLine property. But what if the app is already running? What event is triggered to give the app the hint to look at the System.CommandLine property?

For both platforms, are the sequences given just registering the app as capable of handling the URI, or are they also setting the app as the default handler for the URI?

I posted the Windows way above. But hey, my post was not as fancy. It works like clockworks, though.

My way does not change the user defaults. It simply opens the URI in the default client. It will launch the client if necessary.

And, BTW, here is the Mac method :

dim sh as new shell sh.execute("open http://fontmenu.com") sh.execute("open mailto:tagada@test.com")

I don’t think you read my OP properly. My app is the default client, not some other app. My app is receiving the URI, not sending it out.

Go get it, Tiger.

Yes

No, you need to elevate the app at runtime, you could spawn a new elevated version of your app and close this one, or create an elevated helper who’s sole task it to register the URI then run it if needed. Check the existence of the registry entry from your main app then use the helper to add the registry entry. That is if you don’t want to have an elevated app running all the time which might cause issues as IE might stop elevated apps running from URI’s, I don’t know for sure on that as I’ve not tested it.

It will only create/modify the entry, it wont creat more than one.

The URI system will always spawn a new app. When your app starts, have it check if another is running (mutex) and IPC the information across to that app to handle the new URI request then close down the app that was just created.

I can’t speak for macOS but in Windows, if you register the URI to your app it will be the only one handling it.

Good.

Oh boy.

Good!

Oh boy - again.

OK I see - because there’s just the one registry entry.

Thanks for all that, Julian, although I’m not sure when I’ll get round to working on it. Already, testing my app under Win7 in a VM has highlighted some issues. Still - onwards and upwards, and now at least I know what’s involved.