There are times when it is appropriate for an application to be called via a URL and be passed data, such as "myprotocol://open?id=100”. The following code shows how an application can self register itself to handle a URL protocol.
public void RegisterUrlProtocol(string myUrlProtocolName, bool force,) { RegistryKey rKey = Registry.ClassesRoot.OpenSubKey(myUrlProtocolName, true); if (force || rKey == null) { rKey = Registry.ClassesRoot.CreateSubKey(myUrlProtocolName); rKey.SetValue("", "URL:"+ myUrlProtocolName+" Protocol"); rKey.SetValue("URL Protocol", ""); rKey = rKey.CreateSubKey(@"shell\open\command"); rKey.SetValue("", "\"" + Application.ExecutablePath + "\" %1"); } if (rKey != null) { rKey.Close(); } }
January 2007 | March 2007 | May 2007 | February 2008 | April 2008 | July 2008 | September 2008 | October 2008 | December 2008 | January 2009 | April 2009 | May 2009 | June 2009 | December 2009 | January 2010 |
Subscribe to Posts [Atom]