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?
Go to Start
then in Find
type regedit
-> it should open Registry editor
Click Right Mouse on HKEY_CLASSES_ROOT
then New
-> Key
testus://sdfsdfsdf
) then Click Right Mouse on testus
-> then New
-> String Value
and add URL protocol
without value.New
-> Key
) and create hierarchy like testus
-> shell
-> open
-> command
and inside command
change (Default)
to the path where .exe
you want to launch is, if you want to pass parameters to your exe then wrap path to exe in ""
and add "%1"
to look like: "c:\testing\test.exe" "%1"
Internet Explorer
(not Chrome
or Firefox
) and enter testus:have_you_seen_this_man
this should fire your .exe
(give you some prompts that you want to do this - say Yes) and pass into args testus://have_you_seen_this_man
.Here's sample console app to test:
using System;
namespace Testing
{
class Program
{
static void Main(string[] args)
{
if (args!= null && args.Length > 0)
Console.WriteLine(args[0]);
Console.ReadKey();
}
}
}
Hope this saves you some time.