IUnknown
AddRef()
and Release()
- Functions that return an interface pointer should call
AddRef()
- Functions that use an interface pointer provided by another function are responsible for calling
Release()
- If you copy an interface pointer, the best practice is to call
AddRef()
andRelease()
QueryInterface()
Microsoft defines a bunch of goofy and pseudo-mathematical rules which state in essence that, if you have a pointer to any interface on an object, you can always get a pointer to any other interface on that object, including IUnknown
.