????? ?? ????

?????? ????????? ?????? ?????????
???? ???????: 104138 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

?? ???? ???? ?????? ??? ?????? ??? ????? ???????? ?? ???? ???? ????. ??? ?????? ??? ???? ?????? ???? ????? ??? AddRef() ? Release() ?????? ?? IUnknown. ??? AddRef() ?????? ??? ?????? ????? ???????? ? decrements ????? Release() ????. ????? ???????? ??? ?????? ????? ???????? ??? ??? ? ?? ??? ???? ??? ?????? ???? ??? ??? ???????. ???? ???? ???? ??? ???? ???????? ???? ?? ??? ??? ?? ?????? ???? ????? ???? ?? ??? ???? ??? ?????? ??? ??????.

??????? ????

????? ?? ????

??????? ??????? ?? ????? ?? ???? ?????? ?? ??????? (??? ?? ????? 83 ? 84 ?? ??????? OLE 2.0) ???? ??? ?? ????. ??? ????? ????? ?????? ??????? ?? ??? ??????? ??????? ?? ????? ???????.

  1. ??? ?? ???? ?? ???? ????? ?? ???? ????? AddRef 'd () ? ??? ?? ???? ?? ????? ???? ????? ??????? ???????? ???????? () ??? ??????? ??????? ???? ???? ???? ???? ???.

    1. ?? ?????? ???????? ??????: ??? ?????? AddRef() ??????? ??????, ???? ????? ??????? 'd () ??? ???? ???????? ??? ????? out-value ????.
            LPOLEOBJECT lpObject;
               .
               .  // Get pointer to IOleObject.
               .
            LPVIEWOBJECT lpView = lpObject;
      
            lpObject->AddRef()
      
            // GetViewObject is a theoretical function that takes a
            // pointer to anything derived from IUnknown, and then
            // returns a pointer to IViewObject in the same variable
            // passed as the parameter. The AddRef() above is needed so
            // that the original pointer to IOleObject is not freed.
      
            GetViewObject(lpView);
      								
    2. ????? ????? ?????: ???? ????? ???? ????? ??? ?? ???? ?????? ?? ?????? ?? ????? ????? ??? ???? ????? ?? ???? ???? ??? ???? ????? ????? ?????? ?? ???????? ????? ??????? ???? ?????? ???????.
            void function()
            {
            // Get a pointer to IOleObject from a global variable.
            LPOLEOBJECT lpOleObject = glpObject;
      
            // This AddRef() is needed so that the interface
            // pointed to by the global variable, glpObject,
            // does not get released by a different part of
            // the applications code.
      
            lpOleObject->AddRef();
               .
               . // use lpOleObject;
               .
            lpOleObject->Release();
            }
      								
    3. ?????? ????? synthesized ???? "?????? ????": ???? synthesizes ???? ????? ??????? ????? ?????? ???? ????? ?? ?????? ??? ?? ?? ???? ??? ???? ?????? AddRef() ???? ??? ?????? ?????? ??????. ????? ????? ?????? ??? ??????? ??????? ????? ???? ??????? IUnknown::QueryInterface ???.
            STDMETHDOIMP IUnknown::QueryInteface( REFIID iidInterface,
                                               LPVOID FAR *ppvObj)
            {
            *ppvObj = NULL;
            SCODE sc = E_NOINTERFACE;
      
            if (iidInterface == IUnknown)
                {
                *ppvObj = this;
      
                // This AddRef() is needed because a new pointer
                // was just created.
      
                AddRef();
               sc = S_OK;
                }
      
            return ResultFromScode(sc);
            }
      								
    4. ????? ???? ???? ??????? ???????: ????? ????? ?????? ???????? ???? ?? ???? ????? ?????? ?? ??? ??? ???? ?????? ??????? ??????? ?? ??????. ????????? ??? ???? ???????? AddRef() ??? ?????? ??? ?????? ????.
            // m_lpOleObject is a private member variable of a C++ class.
            // GetOleObject is a member function to return access to this
            // pointer.
      
            void GetOleObject (LPVOID FAR *ppObject)
            {
                *ppObject = m_lpOleObject;
      
                // This AddRef() is needed due to this rule.
      
                m_lpOleObject->AddRef();
             }
      								
  2. ???? ?????? ????? ???? ?? ???? ???? ?? ????????? ???????? ??? ???????? beginnings ? ?????? ????? ??? ?? ???? ?? ???? ????? AddRef()/Release() ????? ???? ?? ?????.

    1. ??- ?????? ??????: ????? ?????? ?? ???? ????? ???? ?? ?????? ?????? ???? ??? ???? ?? ??? ???????? ?? ???? ?????? ???????? ?????? ??????. ????? ??????? ?????? ????? ?? ???? ????? ???? ????.
            void function (LPOLEOBJECT lpOleObject)
            {
      
            // Can use lpOleObject in this function
            // without doing AddRef() and Release().
      
            }
      								
    2. ?????? ????? ??????? ?? ??????? ??? ?? ??? ??? ???????: ?????? ??????? ??? ?? ?????? ????? ?????? ????? 1 ???? ???? ?????????? ???? ?????. ??? ??????? "? ??? ??? ??????? ?? ????? ?????? ?? ???????? ??? ????????. ????????? ??????? ????? ?? ???? ??????? ??? ????.
            LPVIEWOBJECT lpView;
      
            HERROR hErr = lpOleObject->QueryInterface(IID_IViewObject,
                                                      (LPVOID FAR *)lpView);
      
            if (hErr = NOERROR)
                {
                // The QueryInterface succeeded. lpView does not have
                // to be AddRef()'d because it has already been done
                // by the QueryInterface method.
                }
      								
    3. ????????? ???????: ????? ???? ????? ???? ????? omniscient ??????? ??? ?? ????????? ?????? ?????? ?? ???? ??????. ???????? ???? ???????? ??? ??????? ???? ????? AddRef()/Release() ??????.
            void function()
            {
            LPOLEOBJECT lpTempObject;
               .
               .
               .
            lpTempObject = lpObject;
               .
               .  // lpTempObject can be used
               .  // without reference counting as long as
               .  // it is known that the lifetime of lpObject
               .  // outside of this function call.
               .
            }
      								
    4. Backpointers: ???? ???????? ??? ?????? ????? ??? ?????? A ?B ???? ???? ??? ???. ??? ??????? ??? ???? ???? (??) ????? ??? ??? ???? (?) ? ?? ?????? ?? ?????? ?????? ??? ???? ??? ????? (?? B ??? ?) ????? ?? ???? ?????? ????. ?????? ?? ???? ???? ???? ??? ????? ??? ?? ???????? ???? ????? ????????.

???????

???? ???????: 104138 - ????? ??? ??????: 09/????/1424 - ??????: 3.1
????? ???
  • Microsoft OLE 2.0
  • Microsoft OLE 4.0, ????? ?????? ??:
    • Microsoft Windows NT 4.0
    • Microsoft Windows NT 3.51 Service Pack 5
    • Microsoft Windows NT 4.0
    • Microsoft Windows 95
    • the operating system: Microsoft Windows 2000
????? ??????: 
kbmt kbprogramming KB104138 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????104138

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

 

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