ID: Q166276
The information in this article applies to:
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.
Follow these steps to create a simple MTS component:
1. Click New from the File menu.
2. Click 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.
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. Click 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.
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.
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.
Keywords : TSrvProg kbGrpDSTools
Version : 1.0 5.0
Platform : NT WINDOWS
Issue type : kbhowto
Last Reviewed: October 1, 1998