????? ????? ???? COM ?? ATL

?????? ????????? ?????? ?????????
???? ???????: 173823 - ??? ???????? ???? ????? ????? ??? ???????.
?????? ????? Microsoft Visual C++ .NET (2002) ????? ????????? ???????? ??????? ???? ?? ??????? ?? ??? Microsoft .NET Framework ?????? ????? ????????? ???????? ??? ???????? Microsoft Windows ??????. ????? ????????? ??????? ?? ??? ??????? ??? ??? ????????? ???????? ??? ???????? Visual C++.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??????? ??????? ????? ????? COM ??? ?????? ?? ????? ATL:
  1. ?????? ???? IUnknown ??? ???? ????? ? ????? ??? NULL ?? ??????.
  2. ????? ????? ??????? DECLARE_PROTECT_FINAL_CONSTRUCT ?????? ?????? ?? ??? ??? (????? FinalConstruct) ?????? ?????? ????? ????? ??? ???? ?? decrements ??? 0.

    ??????: ??? ??? ?????? Visual C++ .NET ??????? ????? ??? ??.
  3. ??????? ???? IUnknown ????? ??? ??????? ??????? ??? ????? ??????? COM_INTERFACE_ENTRY_AGGREGATE. ??????? ?????? ?? IID ??????? ???????? ?????? ???? ???? ???.
  4. ????? FinalConstruct() ????? ???????.
  5. ????? FinalRelease() ?????? IUnknown ??? ??????.

??????? ????

??? ??? ???????? ????? ????? ?? ??????? ????? FinalConstruct ??? ????? ????? DECLARE_PROTECT_FINAL_CONSTRUCT ??? ????? ???? ?????.

????? ??? ????? ?? ????? ???? ??????? ?? ????? ?????. ??? ?? ???? ???? COutObj ???? ???? ???? ???, CInnObj.

??? ?????

   class ATL_NO_VTABLE COutObj :
         public CComObjectRootEx<CComSingleThreadModel>,
         public CComCoClass<COutObj, &CLSID_OutObj>,
         public IDispatchImpl<IOutObj, &IID_IOutObj, &LIBID_OUTEROBJLib>
   {
   public:
      COutObj() : m_pInnerUnk(NULL) // Step 1
      {
      }
      DECLARE_GET_CONTROLLING_UNKNOWN()
      DECLARE_REGISTRY_RESOURCEID(IDR_OUTOBJ)
      DECLARE_PROTECT_FINAL_CONSTRUCT() // Step 2

      BEGIN_COM_MAP(COutObj)
         COM_INTERFACE_ENTRY(IOutObj)
         COM_INTERFACE_ENTRY(IDispatch)
         COM_INTERFACE_ENTRY_AGGREGATE(IID_IInnObj, m_pInnerUnk) // Step 3
      END_COM_MAP()

      // Start of step 4
      HRESULT FinalConstruct()
      {
         HRESULT hr;
         CLSID   clsidInner;

         hr = CLSIDFromProgID(L"InnObj.InnObj.1", &clsidInner);
         if (hr == S_OK)
            hr = CoCreateInstance(clsidInner, GetControllingUnknown(),
                                  CLSCTX_INPROC_SERVER, IID_IUnknown,
                                  (void**)&m_pInnerUnk);
         return hr;
      } // End of step 4

      void FinalRelease(){m_pInnerUnk->Release();} // Step 5

      // IOutObj
   public:
      STDMETHOD(Test)();
   private:
      LPUNKNOWN m_pInnerUnk; // Step 1
   };
				
??? ??? ?????? ??????? ?? ??? ?????? ATL ?? ????? ??????? ????????? ???????? ??????? ?????? ???? ??????? ??? CoCreateInstance:
   HRESULT FinalConstruct()
      {
         return  CInnObj::_CreatorClass::CreateInstance(
             GetControllingUnknown(), IID_IUnknown,
             (void**)&m_pInnerUnk);

      }
				

?????

Visual C++ ????? ??? ??????: ??? Visual C++; ??? C/C++ ?????? C++; ????? ???? ??????; ?????? ????? ??? COM ? ATL; ????? ??? COM ?????

Visual C++ ????? ??? ??????: ??? Visual C++; ??? C/C++ ?????? C++; ????? ???? ?????? ?????? ??????? ?????? COM ATL; ????? ?????

???????

???? ???????: 173823 - ????? ??? ??????: 11/????? ??????/1425 - ??????: 3.1
????? ???
  • Microsoft ActiveX Template Library 3.0, ????? ?????? ??:
    • Microsoft Visual C++ 5.0 Enterprise Edition
    • Microsoft Visual C++ 6.0 Enterprise Edition
    • Microsoft Visual C++ 5.0 Professional Edition
    • Microsoft Visual C++ 6.0 Professional Edition
    • Microsoft Visual C++, 32-bit Learning Edition 6.0
    • Microsoft Visual C++ .NET 2002 Standard Edition
    • Microsoft Visual C++ .NET 2003 Standard Edition
  • Microsoft ActiveX Template Library 2.1, ????? ?????? ??:
    • Microsoft Visual C++ 5.0 Enterprise Edition
    • Microsoft Visual C++ 6.0 Enterprise Edition
    • Microsoft Visual C++ 5.0 Professional Edition
    • Microsoft Visual C++ 6.0 Professional Edition
    • Microsoft Visual C++, 32-bit Learning Edition 6.0
    • Microsoft Visual C++ .NET 2002 Standard Edition
    • Microsoft Visual C++ .NET 2003 Standard Edition
????? ??????: 
kbmt kbarchitecture kbhowto KB173823 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????173823

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com