Platform SDK: Team Productivity Update

Setup for the Document Review Application

This section discusses the setup program for the sample document review 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.

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.

During setup, 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 API calls return an empty string, the code skips the calls to the TeamAppManager object. It then either proceeds with an installation that does not register the application with the TPU or returns an error, depending on how you have written the setup code. If the function returns the presence of the TeamAppManager object, it continues as follows:

  Dim oTK As TeamAppManagerLib.TeamAppManager
    Dim sFactoryID As String
    Dim sFriendlyName As String
    
    '*** Register the review 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/review/revw_app_Instantiate_URL.asp", _
                    TAFT_DEPLOY, "Document Review Application", "", _
                    "The document review application is used by teams of technical writers to conduct formal reviews of online documentation presented in compressed HTML (*.chm) files.")
    
     ' Save FactoryID (GUID) for unregistration (if needed):
    SaveSetting "review", "TPU", "GUID", sFactoryID
    
    ' Cleanup
    Set oTK = Nothing

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

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.
sFriendlyName Holds the friendly name of the application, which the FriendlyNameFromGUID function has associated with the GUID passed in.

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

Last, the code calls the SaveSetting function to save the review application to the system registry under the key HKEY_CURRENT_USER\Software\VB and VBA Program Settings\appname\section\key. Calls to the TeamAppManager.UnregisterAppFactory method will use the information stored in this registry location.

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

_COM_SMARTPTR_TYPEDEF(ITeamAppManger, __uuidof(ITeamAppManger));

CComBSTR bstrReviewGuid, bstrReviewFriendlyName;
ITeamAppMangerPtr pTeamAppManger(__uuidof(TeamAppManager));

//Send instantiation URL to AppFactory: 
bstrReviewGuid = pTeamAppManger->RegisterAppFactory("http://myserver/review/revw_app_instantiate_URL.asp", 2, "Review") 

// Pass return value as GUID:
bstrReviewFriendlyName = pTeamAppManger->FriendlyNameFromGUID(bstrReviewGuid);

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 Document Review Application.