| 
| 
HOWTO: Write an MTS Component Using ATL
ID: Q166276
 
 |  The information in this article applies to:
 
 
Microsoft Transaction Server  1.0
Microsoft Visual C++, 32-bit Editions, version  5.0
 
 
 SUMMARY
This article describes how to write a Microsoft Transaction Server (MTS)
component using the Active Template Library (ATL), which is included with
Visual C++ version 5.0.
 
 MORE INFORMATION
Follow these steps to create a simple MTS component:
 Create a New ATL ProjectFrom the File menu Click New.
 
 Select the Projects tab, select the ATL COM AppWizard, and type in the Project name MTSProj1 and Location. Click Create a new workspace.
    Click OK.
 
 On the ATL COM AppWizard screen, select a Server Type of "Dynamic Link
   Library (DLL)" and click Allow merging of proxy/stub code. Click
   Finish.
 
 Confirm the new project information and click OK.
 
 Insert an MTS ComponentClick New ATL Object from the Insert menu.
 
 In the ATL Object Wizard, select Objects in the left-pane, then select
   MS Transaction Server in the right-pane. Click Next.
 
 Click the Names tab of the ATL Object Wizard Properties. Type in a C++
   Short Name of MTSObj1. Do not click OK at this time.
 
 Select the MTX tab and select a Dual Interface. As an option, you can
   also select Support IObjectControl and Can be pooled, which tells
   the MTS run-time environment that your object should be returned to an
   instance pool after deactivation, rather than destroyed. This is,
   however, not required for a minimal component. Click OK to generate the
   component.
 
 Add a Method to Your ComponentIf you do not currently have the project workspace displayed, click
   Workspace from the View menu.
 
 Select the ClassView tab in the project workspace and expand the top
   level to see your class (CMTSObj1) and interface (IMTSObj1) names.
   Right-click on the interface name and select Add Method.
 
 Type in the Method Name Return5 and the Parameters [out]long* and
   click OK. You will not be able to change the Return Type from HRESULT
   because you are implementing a dual interface.
 
 Implement the MethodYou should now be able to build your project and add it to the MTS
Explorer.Implement the CMTSObj1::Return5 method as follows:
      STDMETHODIMP CMTSObj1::Return5 (long* number)
      {
          *number = 5;
          return S_OK;
      } 
 
 Additional query words: 
 
Keywords          : kbATL kbMTS kbMTS100 kbVC500 kbGrpCom kbDSupport TSrvProg kbGrpDSTools Version           : winnt:1.0,5.0
 Platform          : winnt
 Issue type        : kbhowto
 |