Abstract: Have you ever wanted to add a desktop sharing feature to your application so users can share their desktop, monitor, or a process with another user with the click of a button? This blog post introduces you to a new feature of the Lync 2013 API that lets you leverage the power of Lync application sharing within your own application.

A couple of months ago I was asked to build an application-sharing user interface into one of our business tools so that someone could share out an Office application like Word or Excel or view an application shared by a coworker. One of the requirements was that the Lync client runs in a mode called “UI suppression,” where the client UI is hidden and Lync is running as a background process.

With this requirement, I had to create all of the sharing feature UI elements in my application and leverage the Lync background process to power the sharing feature. In order to access the Lync background process from my application, I called methods in the Lync 2013 API to start sharing and used properties of the API to show a shared application view in my application.

Rather than try to describe what my resource sharing feature does, I’ll just show you. Figure 1 shows my application sharing out an Excel document. Notice that I’ve created a yellow border around the Excel spreadsheet? I want to be sure a user knows exactly what is being shared.  

 

Figure 1. An Excel spreadsheet is shared out.

Figure 2 shows my application getting a view of an Excel spreadsheet shared by another user. Notice that my sharing console expands in width when showing a remotely shared resource. If a user stops sharing the spreadsheet, the console returns to its original size.

I can request control of the shared Excel spreadsheet by clicking the Request button in the control action button group. If the sharing user lets me have control, I can actually edit the shared spreadsheet from the sharing console.

 

Figure 2. Showing a remotely shared application.

The sharing feature consists the following features:

  • Contact list for picking people to start a conversation with.
  • List of running applications to pick from.
  • A set of buttons to manage sharing control requests.
  • Two text boxes to send and receive IM text.
  • An application sharing view object that shows the shared application.

My resource sharing console only requires that the Lync client is installed on a computer, but does not need the client to be running. If the Lync client is not running, the sharing console starts it up and signs the user in to Lync.

If you want to add this application-sharing feature to your application, I’ve given you a head-start. The code for the resource-sharing console can be downloaded from the Microsoft Developer Network samples gallery here.

The resource-sharing console was created in Visual Studio as a Windows Forms project using C#. The sample code can be ported to a WPF window with minor changes if you prefer to work with XAML.

Except for a few calls into Win32 API methods, the sharing console code is “200 level” programming that does not call for extensive C# development experience. There is a lot of code though. I’ve added code comments in most of the classes for the less intuitive logic.

Summary

If you need to share a desktop, monitor, or running application but cannot show the Lync UI (a conversation-enabled public kiosk is a good example of this scenario), then the code in my resource-sharing console is exactly what you need. If you have a C# developer on your team, you can take advantage of the resource-sharing console sample code to get a running start.

John Austin is a senior content developer in Microsoft. He has been writing about the Lync programmable platform for 5 years. In his spare time, he races a bicycle for a Seattle area amateur racing team.

 

Additional Information

To learn more, check out the following articles: