Microsoft KB Archive/257467

= How To Remove Code Associated with Selecting the FTM Option in the ATL Object Wizard =

Article ID: 257467

Article Last Modified on 7/15/2004

-

APPLIES TO


 * Microsoft ActiveX Template Library 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, public CComCoClass, public IDispatchImpl { 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 m_pUnkMarshaler;

