Create New Interfaces to the Same Object

In this scenario, the server responds to each OBJID_CLIENT request by obtaining a new interface pointer to the same object.

In the following example code, m_pUIObj is a pointer to an object that supports more than one Component Object Model (COM) interface. Even though an existing object is reused, a new interface pointer is created each time the object is retrieved, so the reference count must be decremented.

   if ((DWORD)lParam == OBJID_CLIENT)
      // Get a new interface to the same object. 
      IAccessible *pAcc = NULL;
      // The following increments the reference count. 
      m_pUIObj->QueryInterface(IID_IAccessible, (LPVOID*)&pAcc); 
      LRESULT lAcc = LresultFromObject(IID_IAccessible, wParam, 
            (LPUNKNOWN) &pAcc); 
      // Release our reference to the object.             
      return lAcc;
   break;  // Fall through to DefWindowProc.