Platform SDK: Team Productivity Update

Setup for the Expense Report Application

This section discusses the setup program for the Expense Report sample application.

The code discussed in this topic implements the methods described in the topic Application Registration on the Team Productivity Update Server. These methods are provided by the TeamAppManager object.

The setup installs the initial files and registers the Expense Report application with the Team Productivity Update. After the Expense Report application has been run through the setup process, the application can be configured and deployed into a Team Workspace.

Hosting an application in the Team Productivity Update requires that the application be installed on Microsoft® BackOffice® Server 4.5. During this installation, the application's setup program makes calls to the Team Productivity Update, making it aware of an available application.

Some application developers may choose to write setup or installation programs that can work in environments other than the Team Productivity Update environment. If this is the case, you need to check for the presence of the TeamAppManager DLL in the system registry. The following code performs this task using function calls to the Microsoft Win32® API:

Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal lngHKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal lngHKey As Long) As Long

Public Function IsTeamAppManagerRegistered() as Boolean
    Dim lHKey As Long
    If RegOpenKeyEx(&H80000000, "CLSID\{DF5B61B9-E205-11D2-9CD5-00C04F79EDD4}", 0&, &H20000, lHKey) Then
        ' Key was found under HKEY_CLASSES_ROOT's CLSID
        IsTeamAppManagerRegistered = True
    End If
    Call RegCloseKey(lHKey)
End Sub

If the Win32 calls return an empty string, the code skips the calls to the TeamAppManager object and proceeds with its installation. If the function returns the presence of the TeamAppManager object, the code continues as follows:

  Dim oTK As TeamAppManagerLib.TeamAppManager
    Dim sFactoryID As String

    '*** Register the expense report application with TPU ***
    ' Create a new instance of the TeamAppManager
    Set oTK = New TeamAppManagerLib.TeamAppManager
    ' Register the application with the TPU and get the new FactoryID (GUID)
    sFactoryID = oTK.RegisterAppFactory("http://myserver/expense/urlPublish.asp", _                    TAFT_FACTORY, "Expense Report Sample AIM Application", "", _
"Expense Report Long Description" sFactoryID)
    
    ' Cleanup
    Set oTK = Nothing

This code sets a reference to a new TeamAppManager object, and then declares the following String variable.

Variable Description
sFactoryID Holds the return value from the RegisterAppFactory method call. This is a GUID associated with the application and passed to the FriendlyNameFromGUID method.

The code then uses sFactoryID to hold the GUID that the RegisterAppFactory method returns. RegisterAppFactory passes in the Instantiation URL and TAFT_FACTORY to indicate that the Expense Report application can't instantiate itself without additional user input. The call can also pass in an optional description for the application. The Team Productivity Update now knows the URL to call each time an administrator approves a request for the Expense Report application.

The following code sample calls the TeamAppManager object from a setup program written in Visual C++®:

_COM_SMARTPTR_TYPEDEF(ITeamAppManger, __uuidof(ITeamAppManger));

CComBSTR bstrExpenseGuid;
ITeamAppMangerPtr pTeamAppManger(__uuidof(TeamAppManager));

//Send instantiation URL to AppFactory: 
CComBSTR bstrUniqueIdentifier;
hr=spITWToolkit->RegisterAppFactory(CComBSTR("http://myserver/myurl.asp"), TAFT_FACTORY, CComBSTR("My Friendly Name"), CComBSTR("http://myserver/iconLocation.ico"), CComBSTR("My long description"), &bstrUniqueIdentifier);

Once setup is complete, an application is available for instantiation in a Team Workspace. This process is explained in the topics under Creating an Instance of the Expense Report Application.