Article ID: 166276 - Last Review: March 3, 2005 - Revision: 1.2

How To Write an MTS Component Using ATL

System TipThis article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
This article was previously published under Q166276

On This Page

Expand all | Collapse all

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.

REFERENCES

For information on obtaining version 2.0, please see the following article in the Microsoft Knowledge Base:
185174  (http://support.microsoft.com/kb/185174/EN-US/ ) INFO: Latest Version of Microsoft Transaction Server

APPLIES TO
  • Microsoft Transaction Services 1.0
  • Microsoft Visual C++ 5.0 Enterprise Edition
  • Microsoft Visual C++ 5.0 Professional Edition
Keywords: 
kbhowto KB166276
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.