Custom protocol opening your application

When you want to give users the ability to quickly navigate to your WinForms application by URL with custom protocol, you just have to define your protocol in a simple registry key 🙂

See http://msdn.microsoft.com/workshop/networking/pluggable/overview/appendix_a.asp, for the Notepad example shown by MS.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\note]
@="URL:Note Protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\note\DefaultIcon]
@="notepad.exe"

[HKEY_CLASSES_ROOT\note\shell]

[HKEY_CLASSES_ROOT\note\shell\open]

[HKEY_CLASSES_ROOT\note\shell\open\command]
@="\"C:\\WINDOWS\\note.cmd\" \"%1\""

… oh, notepad does not uderstand the URL, so here note.cmd

@FOR /F "tokens=1* delims=:" %%a IN ("%~1") DO start notepad.exe "%%b"

Back to Top
%d bloggers like this: