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 Project

  1. From the File menu Click New.


  2. 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.


  3. 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.


  4. Confirm the new project information and click OK.


Insert an MTS Component

  1. Click New ATL Object from the Insert menu.


  2. In the ATL Object Wizard, select Objects in the left-pane, then select MS Transaction Server in the right-pane. Click Next.


  3. 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.


  4. 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 Component

  1. If you do not currently have the project workspace displayed, click Workspace from the View menu.


  2. 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.


  3. 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 Method

  1. Implement the CMTSObj1::Return5 method as follows:
    
          STDMETHODIMP CMTSObj1::Return5 (long* number)
          {
              *number = 5;
              return S_OK;
          } 


You should now be able to build your project and add it to the MTS Explorer.

Additional query words:

Keywords : kbATL kbMTS kbMTS100 kbVC500 kbGrpCom kbDSupport TSrvProg kbGrpDSTools
Version : winnt:1.0,5.0
Platform : winnt
Issue type : kbhowto


Last Reviewed: October 8, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.