title: Does IUnknown::QueryInterface() increment the reference count?
body: <p>If I have an <code>IUnknown *ptr</code>, do I need to call <code>Release()</code> on every interface I obtain through <code>ptr-&gt;QueryInterface()</code>, <strong><em>in addition</em></strong> to calling <code>ptr-&gt;Release()</code> when I'm done with <code>ptr</code>?</p>
  
  <p>I used to think that the answer is "Yes", but <a href="http://msdn.microsoft.com/en-us/library/78xw8kzk.aspx" rel="noreferrer">this quote from MSDN</a> confused me:</p>
  
  <blockquote>
    <p>Occasionally you may need to obtain a weak reference to an object (that is, you may wish to obtain a pointer to one of its interfaces without incrementing the reference count), <em>but it is not acceptable to do this by calling <code>QueryInterface</code> followed by <code>Release</code></em>.</p>
  </blockquote>
  
  <p>I don't understand why that's problematic -- if I call <code>ptr-&gt;QueryInterface()</code> and then call <code>Release</code> on the resulting pointer, shouldn't the reference count on the object still be positive? How does that result in an invalid pointer?</p>