views:

1129

answers:

2

How do I register a custom protocol with Windows so that when clicking a link in an email or on a web page my application is opened and the parameters from the URL are passed to it?

+5  A: 

I think this is covered in MSDN, please see http://msdn.microsoft.com/en-us/library/aa767914.aspx

Jonas Gulle
+3  A: 

The MSDN link is nice, but the security information there isn't complete. The handler registration should contain "%1", not %1. This is a security measure, because some URL sources incorrectly decode %20 before invoking your custom protocol handler.

PS. You'll get the entire URL, not just the URL parameters. But the URL might be subject to some mistreatment, besides the already mentioned %20->space conversion. It helps to be conservative in your URL syntax design. Don't throw in random // or you'll get into the mess that file:// is.

MSalters
What do you exactly mean by "mess that the file://" is?
Maleev
There's no formal mapping of file: URLs to local paths. There's not even a consensus on the use of two or three leading slashes, or the use of forward versus backward slashes when the path refers to a Windows directory.
MSalters
Late comment, I know. But is it also possible to somehow access the URL parameters *only*, without the protocol handler?
danilo
That sounds like a separate question. Please do get your terms straight, though. The protocol handler is the program that receives the URL. "Without the protocol handler" there's nobody to parse the URL and access the URL parameters.
MSalters