Deliberations

Thoughts on the problems and solutions I work with every day, along with musings on random topics

NAVIGATION - SEARCH

Custom Protocol Handler

Have you ever wanted to define a link on a webpage to open a specific, different browser? Perhaps you have a corporate application that only supports Firefox (or Chrome) but your main application set works only in IE.

Well, in Windows at least, you can define your very own custom protocols - Microsoft describes how to do that in MSDN. In fact as you can see at the bottom, they even have some sample code.

The problem with that particular implementation is that it relies on the application being called knowing how to process the "custom" protocol. So Firefox would have to know (be specifically programmed to know) that a firefox://www.google.com URL should really be interpreted as http://www.google.com.

To solve this I've written a shim application that lets you define your own mapping of custom protocol to application+real protocol. Any application that allows Windows to "do its thing" with a URL should be able to find and execute the custom handler, which identifies the correct program to run and loads it up with the corrected URL.

Example

Configure your URL types in the app.config file.  There are three parts to a setting - the custom protocol, the application path and the "true" protocol.

These settings are stored in the form:
      CustomProtocol=Application Path,Protocol

For example, to handle URIs with a new protocol called "cisco" you might define a setting as shown:
      cisco=C:\Program Files\PuTTY\putty.exe,ssh

Calling this application with the command line
      cisco://10.1.4.54
would then cause this application to run:
      C:\Program Files\PuTTY\putty.exe ssh://10.1.4.54

Code (and eventually, downloadable application) located at GitHub for ease of access.