Share Application Homepage on Linkedin, Twitter and Facebook

Many webpages have buttons that allow sharing with other people by using social networking services like Linkedin, Twitter, Facebook, and so on. Would be a good idea to include something similar in our own desktop application. This can be made quite simple: just format an URL string which contains the specific “sharer” URL and, as a parameter, the application’s homepage URL. Finally, we can pass that URL string to ShellExecute function, like in following example:

We can use similar code for Twitter and Linkedin. Here are the specific URLs:

  • Linkedin: http://www.linkedin.com/shareArticle?mini=true&url=site_url
  • Twitter: http://twitter.com/share?url=site_url
  • Facebook: http://www.facebook.com/sharer.php?u=site_url

Until now, no sweat! However, opening an external browser may be annoying for a user, so it’s better to display the sharer page in a window of our own application. For that purpose I wrote CUrlSharerDialog class.

CUrlSharerDialog class

CUrlSharerDialog is derived from CDialog MFC class. It contains a Microsoft Web Browser ActiveX control for displaying the sharer page without opening an external browser. Behind the scene, most of the job is done in CUrlSharerDialog::_Navigate2Sharer.

And here is an example showing how to use CUrlSharerDialog class in your application for sharing on Linkedin site.

For more implementation details, as well as usage detils, see the attached demo project.

Demo project

The demo project is a dummy dialog-based application which does nothing else than demonstrates how to use CUrlSharerDialog in an MFC application.

Share Application Homepage - Demo

Share Application Homepage – Demo

Resources

Downloads

Leave a Reply