Export (0) Print
Expand All
Expand Minimize

Using Registry Metadata for Easier Data Access in Lync 2010 Contextual Conversations

Summary:   Use application registration parameters for quick access to contextual data, application name, and application GUID in Microsoft Lync 2010 contextual conversations.

Applies to:   Microsoft Lync 2010 SDK | Microsoft Lync 2010

Published:   March 2011 | Provided by:   John Clarkson, Microsoft About the Author

Contents

Lync 2010 contextual applications require registration to identify and configure the applications. For more information, see Registering Contextual Conversation Packages. Registration is required for every contextual application. You can also add parameters to the registry entry for a contextual application that specify data items that you want to retrieve. Use the techniques that are discussed in this article to extract contextual data, application name, and application GUID from the Lync 2010 application cache. The three parameters appearing in the next table may be added to the Parameters value that is located in the registry key for a Lync 2010 contextual application.

Parameter

Description

%AppData%

Use this parameter to obtain contextual data. The value is the same as the value of the ConversationContextualInfo.ApplicationData property.

%AppId%

Use this parameter to obtain the application GUID. The value is the same as the value of the ConversationContextualInfo.ApplicationId property.

%AppName%

Use this parameter to obtain the application name. The value is the same as the Registry Name value.

You can read these parameter values in your code. This article describes how to create a working example by using a Lync 2010 Windows Presentation Foundation (WPF) application to send an instant message (IM) that contains contextual data, and then on the computer that receives the IM, read the parameter values in either a desktop or a web application.

Figure 1. Reading application cache data

Registry data

For information about how to create and register an application to start an IM conversation that contains contextual data, see Using Lync Controls to Send Contextual Data. The next section shows how to use registry parameters and code to retrieve data from the application cache on the receiving computer.

The technique that is used to obtain parameter values is different depending on whether your application is a Microsoft Windows desktop application, or a web application. This section shows how to use a Windows Forms application and a web page to retrieve data from the cache that is controlled by the application that receives the message.

  • In a desktop application, use the Environment.GetCommandLineArgs method to retrieve parameter values.

  • In a web application, use HTML or JScript code to retrieve parameter values.

Both options are discussed in the following examples.

Get Parameter Values in a Desktop Application

A Windows Forms application together with C# is used in the next procedure. However, the information can be used with other languages and kinds of applications.

To create the desktop application

  1. Create a Windows Forms application.

  2. Add a TextBox control and size it to display 4 lines of text, 80 characters long.

  3. Add the following code to Form1.cs. The GetCommandLineArgs method situates the executable path in the first element of the array.

    String[] arguments = Environment.GetCommandLineArgs();
    textBox1.Text =
      "Executable path = " + arguments[0] + Environment.NewLine +
      "Contextual data = " + arguments[1] + Environment.NewLine +
      "Application GUID = " + arguments[2] + Environment.NewLine +
      "Application name = " + arguments[3] + Environment.NewLine;
    
  4. Add the appropriate Windows registry entries. Ensure that "Path"= includes a valid value. A comma and space are required to separate the items that appear in the Parameters value.

    [HKEY_CURRENT_USER\Software\Microsoft\Communicator\ContextPackages\{your application GUID}]
    "Name"="BlueYonderAirlines"
    "Path"="C:\YourParameterApp.exe"
    "Parameters"="%AppData%, %AppId%, %AppName%"
    

To display parameters in your desktop application

  1. On the sending computer, start the Microsoft Lync Controls application and then send an IM message to the receiving computer.

  2. On the receiving computer, click the toast.

  3. In the conversation window, click the context link that appears in the message. The parameter data appears in the desktop application.

Figure 2. Parameter data

Arguments

Get Parameter Values in a Web Application

A Microsoft Silverlight application together with JScript is used in the next procedure. However, the information can be used with other languages and kinds of applications.

To create the web application

  1. Create a Silverlight application, and select the Host Silverlight application in a new Web site option.

  2. In the .html page that is created for the project, add the following JScript.

    document.write(window.location.search);
    
  3. Add the appropriate Windows registry entries. Ensure that "InternalURL"= includes a valid value. Parameters are added to the InternalURL value as a query string.

    [HKEY_CURRENT_USER\Software\Microsoft\Communicator\ContextPackages\{your application GUID}]
    "Name"="BlueYonderAirlines"
    "InternalURL"="C:\SL SLParametersTestPage.html?name=%AppName%;id=%AppId%;data=%AppData%"
    

To display parameters in your web application

  1. On the sending computer, start the Lync Control application and then send an IM message to the receiving computer.

  2. On the receiving computer, click the toast.

  3. The web application together with the parameter data appears in the Conversation Window Extension (CWE).

Figure 3. Data appearing in the CWE

Silverlight arguments

In Lync 2010 contextual conversation applications, use the application cache to simplify how you access the application name and GUID, and contextual data. Instead of using the Microsoft Lync 2010 SDK object model or accessing the RegistryKey object, you can use the procedures appearing in this article to streamline how you obtain data values.

John Clarkson is a programming writer with the Microsoft Lync product team.

Show:
© 2015 Microsoft