Search code examples
windowsregistryprotocols

Why does windows pass full custom url including protocol to handling application?


I am trying to create my own URL protocol to initate a custom application from a URL in our internal CRM.

I have created the following registry entry as such:

REGEDIT4

[HKEY_CLASSES_ROOT\smon1]
@="URL:smon Protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\smon1\shell]

[HKEY_CLASSES_ROOT\smon1\shell\open]

[HKEY_CLASSES_ROOT\smon1\shell\open\command]
@="\"C:\\smon.exe\" \"%1\"" 

I have the following link on my site:

<a href='smon:1955'>1955</a>

I would expect this to pass the variable 1955 to the aplication c:\smon.exe. However it is passing the entire variable "smon:1955".

Why is it passing everything instead of the variable?

What am I missing here?


Solution

  • Your not missing anything, that's how the handlers work; the whole URI is passed in the command line. Detect and parse it away.

    The rationale is presumably that it allows multiple protocols to be associated with the same executable without needing to provide custom discriminatory switches in the command key.