if I make my own QueryInterface, do I have to call AddRef
automatically inside QueryInterface, or does it the calling
Posted on 2001-12-13 09:10:04 by beaster
It would work out fine either way, as long as everyone was consistant, right?

That's whay the COM contract insists that QueryInterface do the AddRef. In fact, proper coding practice dictates it do exactly that:

call AddRef;

as opposed to:

RefCount ++;

(The latter is only correct for a single threading ernviroment.)

In general, if you pass out an interface you AddRef it.

And if something hands you an interface you Release it when done.
Posted on 2001-12-14 00:30:01 by Ernie