DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
What's in store for DevOps in 2023? Hear from the experts in our "DZone 2023 Preview: DevOps Edition" on Fri, Jan 27!
Save your seat
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Walkthrough: Using Windows 8 Custom Protocol Activation

Walkthrough: Using Windows 8 Custom Protocol Activation

Jerry Nixon user avatar by
Jerry Nixon
·
Oct. 25, 12 · Interview
Like (0)
Save
Tweet
Share
9.60K Views

Join the DZone community and get the full member experience.

Join For Free
Protocol activation, what is it? Well, when you run “http:{something}” you expect a browser to launch, right? When you type “mailto:{something}” you expect a mail client to launch, right? What if you could create “custom:{something}” that launched your app? That’s custom protocol activation!

MSDN: Windows allows an app to register to become the default handler for a certain URI scheme name. Both desktop and Windows Store apps can register to be a default handler for a URI scheme name. If the user chooses your app as the default handler for a URI scheme name, your app will be activated every time that type of URI is launched. You should only register for a URI scheme name if you expect to handle all URI launches for that type of URI scheme. If you do choose to register for a URI scheme name it is important that you provide the end user with the functionality that is expected when your app is activated for that URI scheme. For example an app that registers for the mailto: URI scheme name should open to a new e-mail message so that the user can compose a new e-mail. For more info on file associations see Guidelines and checklist for file types and URIs.

Here’s a quick protocol demo

Not just any ole protocol

MSDN:  Here is an alphabetic list of URI scheme names that you cannot enter into the package manifest because they are either reserved or forbidden: Application.manifest, Application.reference, Batfile, BLOB, Cerfile,Chm.file, Cmdfile, Comfile, Cplfile, Dllfile, Drvfile, Exefile, Explorer.AssocActionId. BurnSelection,Explorer. AssocActionId.CloseSession, Explorer.AssocActionId. EraseDisc, Explorer.AssocActionId. ZipSelection,Explorer. AssocProtocol.search-ms, Explorer.BurnSelection, Explorer.CloseSession, Explorer.EraseDisc, Explorer.ZipSelection, FILE, Fonfile, Hlpfile, Htafile, Inffile , Insfile, InternetShortcut, Jsefile, Lnkfile,Microsoft.PowerShellScript.1, MS-accountpictureprovider, Ms-appdata, Ms-appx, MS-AUTOPLAY, Msi.Package,Msi.Patch, Ms-windows-store, Ocxfile, Piffile, Regfile, Scrfile, Scriptletfile, Shbfile, Shcmdfile, Shsfile, SMB,Sysfile, Ttffile, Unknown, userTileProvider,vbefile, Vbsfile, Windows.gadget, Wsffile, Wsfile, Wshfile.

Some find things to try

The Bing Maps app that comes installed on Windows 8 supports protocol activation. This means you can create shortcuts into it. It also means you can leverage it from your application. In fact many apps that include the Bing Maps control, really shouldn’t. Try running this:

bingmaps:?q=coffee&where=Omaha

Application Manifest

MSDN: The file type and protocol association model has changed in Windows 8. Apps are no longer able to programmatically set themselves as the default handler for a file type or protocol. Instead, now the user always controls what the default handler is for a file type or protocol.

image

That screen above is the application manifest. It’s on the declarations tab where we can add the “protocol” declaration.

MSDN: Your app can use existing protocols for communication, such as mailto, or create a custom protocol. The protocol activation extension enables you to define a custom protocol or register to handle an existing protocol.

Let’s take it to another level!

In the video above, one key operation was for my application to call a Uri. To do this in C#,  we use LaunchUriAsync and pass in the Uri we want to launch. Like this:

image

Security considerations

MSDN: As noted above, the URL that is passed to an application protocol handler might be broken across multiple parameters. Malicious parties could use additional quotation marks or backslash characters to pass additional command-line parameters. For this reason, application protocol handlers should assume that any parameters on the command line could come from malicious parties, and carefully validate them. Applications that could initiate dangerous actions based on external data must first confirm those actions with the user. In addition, handling applications should be tested with URLs that are overly long or contain unexpected (or undesirable) character sequences.

Conclusion

Why not? Protocol activation is just another cool way to activate your app. It’s easy (I hope that’s obvious) and doesn’t cost you a thing. And, maybe, just maybe, you can do even more than you originally dreamed with your app – engage imagination.

Best of luck!

 

 

 

Protocol (object-oriented programming) app application Uniform Resource Identifier Scheme (programming language)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Better Performance and Security by Monitoring Logs, Metrics, and More
  • Top 10 Secure Coding Practices Every Developer Should Know
  • Differences Between Site Reliability Engineer vs. Software Engineer vs. Cloud Engineer vs. DevOps Engineer
  • Kubernetes vs Docker: Differences Explained

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: