Register a custom protocol in Windows

Asked

Viewed 193 times

2

I don’t know if I’m asking you correctly, but I don’t know where to start looking. I would like to register a custom protocol in windows like some applications do. Example:

  • Spotify -> Spotify:
  • Torrent -> Magnet:
  • email -> mailto:

Where do I start my search? I imagine it is necessary to write in the windows registry but I don’t know how to search on this specific case.

1 answer

2


These protocols are called URI schemes. You can create protocols for your project using URI schemes in the Windows registry by navigating the path:

HKEY_CLASSES_ROOT/
   seu_protocolo_aqui/
       (Default)              = "URL:nome do protocolo"
       URL Protocol           = ""
       DefaultIcon
           (Default)          = "aplicativo.exe,1"
       shell
           open
               command
                    (Default) = "C:\Users\Kaizonaro\Desktop\aplicativo.exe" "%1"

Wherever seu_protocolo_aqui the protocol you want to associate in the URIS (for example mailto:, blablabla: without the :), and in the "protocol name" any name for Windows recognize in your application.

Let’s put as in the seu_protocolo_aqui for foobar, we would call your application using the arguments like this:

foobar:ola%20mundo //either in the %20 a character of space

To get what was called in the argument ola%20mundo just use the function Command()

If you want more information on how to use URI schemes on Windows with . NET Framework, take a look at this link here.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.