www.RickLaFleur.com

 

Open an App using a Registered URL

I found this code snip at Christina's site and found it works well with any registered URL, including those custom URL Protocols that you may register .

  
string url = @"http://www.ricklafleur.com";
Process.Start("rundll32.exe", "url.dll,FileProtocolHandler \"" + url + "\"");

Labels: ,


 

Register Application as a Url Protocol

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();
    }
}

Labels: ,


Archives

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  |  

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]