Associating a URL Protocol to your ApplicationNo Comments
This is something done by WebPI (wpi://) and many p2p apps that you can do with your own application also: associate a URL protocol to your application. Let’s say you want to use URLs beginning with myapp:// to launch your own application and perform a certain task (i.e. download a file and open it). This is simply done by adding some entries in the registry, the following steps guides you on how to configure your setup project to do this.
- Right click on the Setup project of your solution, go to View and select Registry.
- Under HKEY_CLASSES_ROOT create a new key and use the name for your protocol, let’s say “myapp“.
- Add a new String value and delete the name, now it should appear with the name (Default).
- Set the value to “URL:myapp Protocol”.
- Add another String value and name it “URL Protocol“. Leave its value blank. The registry view should now look like the following screenshot:
- Under the “myapp” key created on step 2, create a new key and named it “shell“.
- Under the “shell” key create a new one named “open“.
- Under the “open” key create a new one named “command“.
- Add a new String value under the “command” key and delete its name to make it the default value.
- Set the default value to ““[TARGETDIR]MyApplication.exe” “%1″“. The registry view should now look like the following screenshot:
That’s all!, each time the user hits a URL with your custom protocol, your application will be executed and will receive the URL. Now you have to parse it and act accordingly.
Additional reading: Registering an Application to a URL Protocol
Leave a comment
Your email address will not be published.