Creating a new URL protocol

  • Thread starter Thread starter Richard Gadsden
  • Start date Start date
R

Richard Gadsden

In Windows, there are a number of protocols, like mailto: and http:
which then hand over to an application.

How do I create a new one?

I want to create a phone: protocol, so I can have intranet pages with <a
href="phone:2468">Extension 2468</a> and people can then just click on
the extension number and their phone will dial it.

I've got an application that will dial a number if it's passed that
number on the command line, but I can't work out how to make phone:2468
turn into a command-line. I guess I need to register it as a handler
for the phone protocol, but I don't know how to do that; I more-or-less
understand the process for file extensions, but I've never looked at it
for URL protocols before.

Help!
 
Hi,

Richard said:
I want to create a phone: protocol, so I can have intranet pages with
<a href="phone:2468">Extension 2468</a> and people can then just
click on the extension number and their phone will dial it.

This is certainly possible, but usually done programmatically, by the
installer program of whatever you are installing. The process is almost
exactly the same as registering an application to handle a new file
extension.

Here's how I would go about it if I were you (usual warnings about editing
registry apply):

1) Using regedit, add a new key under HKEY_CLASSES_ROOT and name in "phone";

2) Select the new key and modify its "(Default)" value to some reasonable
short description, such as "Phone Dialer hack". This name will be used by
shell UI.

3) Under the new key, add a new string value and name it "URL Protocol".
Leave it empty.

4) Add a new binary value and name it "EditFlags". Modify its value and
enter the bytes "00 01 00 00".

5) We aren't done yet, but the above should suffice to make remaining
details editable through the shell's "File Types" dialog -- which, I dare
say, is more convenient. So, close regedit and go to any shell window,
"Tools" -> "Folder Options..." -> "File Types".

6) Find our new protocol, which should show "(NONE)" for extensions and have
the description from step #2. Select it and click the "Advanced..." button.

7) Click "New" to add an action. Name it "open" and select or enter path to
your dialer application. Add any necessary command line switches. "%1"
signifies the URL, so the finished entry might look like this:

"c:\path\to\my\dialer.exe" "%1"

8) Now we are done. Test, tweak, export the HKEY_CLASSES_ROOT/phone key to
a file, for deployment to your client machines.

When your application is launched, the argument passed to it is going to be
the complete URL. The dialer should be able to hande "phone:2468", because
that is what it will get.

If necessary, it should be fairly easy to come up with some sort of a
wrapper executable, perhaps even a shell script, that strips the "phone:"
part. I wouldn't be very surprised if this behavior can also be controlled
by one of the BrowserFlags bits, or something of that nature...

Docs:

http://msdn.microsoft.com/library/e...sics_extending/fileassociations/fileassoc.asp

Hope that helps,
 
Richard,

You can create protocols just because.... but have you tried to call your
application by that link?

something like:
<a href:"application.exe extension">extension</a>

it might work depending on how to pass parameters to your application

RT
 
Back
Top