Do you support URLs on Windows Forms applications?
Updated by Igor Goldobin 1 year ago. See history
Aside from ease of installation, what is the one thing a web browsers has over a Windows Forms application? - a URL!
With a Windows Forms application, you typically have to wade through layers of menus and options to find a particular record or "page". However, Outlook has a unique feature which allows you to jump to a folder or item directly from the command line.

Figure: Outlook can automatically jump to a specified folder or item from a command line

Figure: Outlook address bar (Web toolbar) shows you the URL for every folder
We believe that all applications should have this capability. You can add it to a Windows Application using the following procedure:
- Add the necessary registry keys for the application
- HKEY_CLASSES_ROOT\AppName\URL Protocol = ""
- HKEY_CLASSES_ROOT\AppName\Default Value = "URL:Outlook Folders"
- HKEY_CLASSES_ROOT\AppName\shell\Default Value = "open"
- HKEY_CLASSES_ROOT\AppName\shell\open\command\Default Value = "Path\AssemblyName.exe /select %1"
- Add code into your main method to handle the extra parameters
C#:
public static void Main(string[] args){...if(args.Length > 0){string commandData = args[1].Substring(args[1].IndexOf(":") +1).Replace("\"", String.Empty);Form requestedForm = null;switch(commandData){case "Client":{requestedForm = new ClientForm();break;}// Handle other valuesdefault: // Command line parameter is invalid{MessageBox.Show("The command line parameter specified" +" was invalid.", "SSW Demo App",MessageBoxButtons.OK, MessageBoxIcon.Error);// Exit the applicationreturn;}}requestedForm.Show();// Show the main form as wellMainForm mainForm = new MainForm();mainForm.Show();// Give the requested form focusrequestedForm.Focus();Application.Run(mainForm);}else // No command line parameters{// Just show the main formApplication.Run(new MainForm());}}
VB.NET:
Public Shared Sub Main()...
Dim args As String = Microsoft.VisualBasic.Command()If args.Length > 0Dim commandData As String = _args.Substring(args.IndexOf(":") + 1).Replace("""", "")Dim requestedForm As Form = NothingSelect Case commandDataCase "Client"requestedForm = New ClientForm()' Handle other valuesCase Else ' Command line parameter is invalidMessageBox.Show("The command line parameter specified " &_"was invalid.", "SSW Demo App", MessageBoxButtons.OK, &_MessageBoxIcon.Error);' Exit the applicationExit SubEnd SelectrequestedForm.Show()' Show the main form as wellDim mainForm As MainForm = New MainForm()mainForm.Show()' Give the requested form focusrequestedForm.Focus()Application.Run(mainForm);Else ' No command line parameters, just show the main formApplication.Run(new MainForm())End IfEnd Sub
Sample code implementation in the SSW .NET Toolkit