Register a custom protocol in Windows

2

I do not know if I'm asking correctly, but I do not know where to start searching. I would like to register a custom protocol on windows just as 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 do not know how to search about this specific case.

    
asked by anonymous 08.02.2016 / 03:49

1 answer

2

These protocols are called URI Schemas . You can create protocols for your project by using URI schemas 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"

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

Let's put as in seu_protocolo_aqui to foobar , we'd call your application using the arguments like this:

foobar:ola%20mundo // be in %20 a space character

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

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

    
12.02.2016 / 20:19