The Grayzone

Custom URL Protocol in Windows CE

The Problem

One requirement for my current application is that when the user clicks on a specific link on a web application from their Windows Mobile device, a pre-installed application will be launched on the device and a parameter from the web application will be passed to the application.

The Solution

I decided to use a custom URL Protocol (like http, mailto, ftp etc) to launch the application and pass parameters that way. This would work in the same way as ‘’. This launches the default e-mail program and passes in the e-mail address as an argument. For this article I’ll create the protocol ‘launch’, e.g. ‘launch:my_param’.

Registry Settings

It turns out to be fairly straight forward to get this up and running. First off I found this MSDN article on registering a URL protocol. I found this very helpful but there is an extra registry entry required for Windows CE, below are all of the registry entries that need to be made.

  1. [HKEY_CLASSES_ROOT\launch] “URL Protocol”=”” “(Default)”=”URL:Launch Protocol” The important part here is the “URL Protocol” as this specifies that the entry is a URL Protocol.

  2. ```bash [HKEY_CLASSES_ROOT\launch\Shell]


[HKEY_CLASSES_ROOT\launch\Shell\Open\Command] @=”"\Program Files\MyApp\MyApp.exe" "%1"”

“\Program Files\MyApp\MyApp.exe” “%1” specifies the application that is to be launched and the “%1” part ensures that any arguments will be passed to this application.

3. `[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shell\URLProtocols\launch]`
This is the last registry entry that you need and is omitted from the above MSDN article.

## Application
To test the URL Protocol I made a standard Device Application. Within the program.cs that is created I changed the Main method to take in a string array of arguments. I then added a string parameter to the constructor of Form1

public static void Main(string[] args)
  string param = string.Empty;
  if (args != null && args.Length > 0)
    param = args[0];

  Application.Run(new Form1(param));

public Form1(string parameter)
  label1.Text = string.Format("Passed in value is: {0}", parameter);

Now when you click on a the following link: “launch:test_param” the application will launch and display the parameter. Without any filtering the whole link will be passed in (i.e. with the “launch:” prefix).

Share this: