Tibia Player
Tibia Player

Reputation: 13

Run application from browser

I could not find any information about this. I am sure there is a term for this type of applications, but I have no idea where to look. That's why I decided to ask here.

So there are a few websites where you hover over a link or button it says something like application:xyz where application usually is the name application to run, and the xyz are the parameters or something.

An example is all the torrent links. If you hover over a link there it says
magnet:?somethingxxxxxxxxxxxx how can I bind my own custom application to a certain URL?

Let's say I have a C# application I call Musiclist. I want to make URLs like: musiclist:?song=hey123

And when I click it in my browser, it opens the application.

I really could not find anything about this with some examples, or how I pass those variables in with the :? in the link, so that's why I cannot provide any code examples.

Upvotes: 1

Views: 537

Answers (1)

Visual Vincent
Visual Vincent

Reputation: 18320

This is what's called a protocol or a URI Scheme.

This is defined in the registry, so you'd have to add the correct values there:

HKEY_CLASSES_ROOT
    <protocol>
        (Default) = "URL:<protocol name>"
        URL Protocol = ""
        DefaultIcon
            (Default) = "<path to your application>,<icon index>"
        shell
            open
                command
                    (Default) = "<path to your application>" "%1"

In your case this could for example be:

HKEY_CLASSES_ROOT
    musiclist
        (Default) = "URL:Music list protocol"
        URL Protocol = ""
        DefaultIcon
            (Default) = "C:\Program Files\Musiclist\musiclist.exe,0"
        shell
            open
                command
                    (Default) = "C:\Program Files\Musiclist\musiclist.exe" "%1"

Everything after the colon (:) will be passed to your application as (a) Command Line Argument(s).

Upvotes: 2

Related Questions