How To Remove Code Associated with Selecting the FTM Option in the ATL Object Wizard (257467)



The information in this article applies to:

  • The Microsoft Active Template Library (ATL) 3.0

This article was previously published under Q257467

SUMMARY

This article demonstrates how to remove the Free Threaded Marshaler support from an Active Template Library (ATL) component.

MORE INFORMATION

When you create an ATL component using the New ATL Object option from the Insert menu, then the Free Threaded Marshaler option can be selected by the user in the Attributes tab. To remove this Free Threaded Marshaler support from an ATL component after the fact, add the following code sample. Note that all of these changes go in to the component's header file and the lines need to be commented as shown below, that is marked with // **.

class ATL_NO_VTABLE CIFTMTEst2 : 
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CIFTMTEst2, &CLSID_IFTMTEst2>,
	public IDispatchImpl<IIFTMTEst2, &IID_IIFTMTEst2, &LIBID_SHAYLib>
{
public:
	CIFTMTEst2()
	{
// ** Because you don't need this variable, then you don't need to initialize it.
// **		m_pUnkMarshaler = NULL;
	}

DECLARE_REGISTRY_RESOURCEID(IDR_IFTMTEST2)
DECLARE_GET_CONTROLLING_UNKNOWN()

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CIFTMTEst2)
	COM_INTERFACE_ENTRY(IIFTMTEst2)
	COM_INTERFACE_ENTRY(IDispatch)
// ** Remove the entry for IMarshal, because it was only there for the Free Threaded
// ** Marshaler.
// ** COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
END_COM_MAP()
	HRESULT FinalConstruct()
	{
// ** Comment out the Free Threaded Marshaler creation.
// **        return CoCreateFreeThreadedMarshaler(
// **			GetControllingUnknown(), &m_pUnkMarshaler.p);

// ** Replace with a standard HRESULT, S_OK, or return an appropriate 
// ** HRESULT depending on any other calls that you make in 
// ** FinalConstruct().
             return S_OK;
	}

	void FinalRelease()
	{
// ** Comment out the Release of the Free Threaded Marshaler.
// **		m_pUnkMarshaler.Release();
	}
 
// ** You don't need this variable holding the Free Threaded Marshaler
// ** reference:
// **	CComPtr<IUnknown> m_pUnkMarshaler;

				

REFERENCES

  • For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

    256217 INFO: FTM usage

  • ActiveX Q&A Microsoft Systems Journal September, 1997 - Apartment Neutrality: The Free Threaded Marshaler and the Global Interface Table

Modification Type:MinorLast Reviewed:7/15/2004
Keywords:kbhowto KB257467