Should I release all my IDispatch pointers?

Hi all,

I have an OLE question I don't see answered on MSDN: when is it correct to Release() an IDispatch pointer?

In one of my destructors I have:

1
2
3
4
5
6
if (dispatch != 0) {
   uint32_t ref_count;
   while ((ref_count = dispatch->Release()) > 0) { }
   assert(ref_count == 0);
   dispatch = 0;
}


which makes very, very sure the IDispatch is dead before OLE shuts down. But I also have a number of IDispatch pointers to descendant interfaces returned by IDispatch::Invoke. Is it correct to Release() those too?

Thanks.
Topic archived. No new replies allowed.