Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows URL scheme call to running program

I want to trigger an event in my running application and deliver arguments with the call of a URL scheme in Windows 10. I made the following registry entry:

HKEY_CLASSES_ROOT
alert
    (Default) = "URL:Alert Protocol"
    URL Protocol = ""
    DefaultIcon
        (Default) = "alert.exe,1"
    shell
        open
            command
                (Default) = "C:\Program Files\Alert\alert.exe" "%1"

Obviously, this always starts a new instance of my application with an argument, when calling 'alert:arg1'. But I want Windows to call my already running instance.

With Mac, the call of this URL scheme triggers an event, I can catch. Exactly, as I want. To do this, I added the following part to alert.app/Contents/Info.plist:

<array>
  <dict>
    <key>CFBundleURLName</key>
    <string>Alert</string>
    <key>CFBundleURLSchemes</key>
    <array>
            <string>alert</string>
    </array>
  </dict>
</array>

So how do I realise this on Windows? I'm programming this application in XOJO with object-oriented BASIC, but I'll be happy about a general solution.

like image 208
Robert Beier Avatar asked Oct 29 '25 04:10

Robert Beier


1 Answers

Well, after reading the answer of Alex, I searched how to realise this with code and found a well explained and working solution from Brad Smith written in C#.

The registry entry above can stay as it is, but the program also needs:

  • A service class (which is exposed by the application instance
    via .NET remoting)
  • A modified entry point (which will either communicate with the service and then terminate, or start the application normally)

Read his article and look at his code for further explanation.

like image 53
Robert Beier Avatar answered Oct 31 '25 20:10

Robert Beier



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!