Search code examples
wpfhyperlinkregistry

WPF application - create custom hyperlinks


We are developing a WPF application and we have a requirement that a user can open certain screen and they need an option to create link and then paste them outside of the application like outlook or Skype etc... Once they paste it should appear as a link and when they click on the link it should open the application and navigate to the screen for which the link was created. To achieve this we are trying to create a custom links like appname://, and on clicking we are trying to open the application and pass the guid as parameter. Can you point us on how to create custom links and map them to navigate to particular exe on clicking?


Solution

  • You'll have to register your own URI Scheme in the registry and link it to your application executable path

    HKEY_CLASSES_ROOT
    
    
    alert
          (Default) = "URL:Alert Protocol"
          URL Protocol = ""
          DefaultIcon
             (Default) = "alert.exe,1"
          shell
             open
                command
                   (Default) = "C:\Program Files\Alert\alert.exe" "%1"
    

    You can read more on it here