On Mon, 16 Jun 2003 14:43:25 -0500, Sir Kelly Leahy scribed thus:
I would expect you to addref the typelib when the ITypeInfo pointer is created, and then when it is destroyed to release it.
I believe that's what I'm doing. Maybe not.
I think what is actually going on, is that this method returns a pointer to an internal interface that's always present. There is no construction as such. From MSDN:
HRESULT GetTypeInfoOfGuid( REFGUID guid, ITypeInfo FAR* FAR* ppTinfo ); Retrieves the type description that corresponds to the specified GUID.
This confuses me. Does the caller need to release the interface? The page doesn't mention refcounting at all.
"Retrieves" is somewhat fuzzy. The fact that it's a pointer to a pointer suggests that maybe you get a pointer to an internal interface and you shouldn't do any refcounting on it.
In the object that implements the ITypeInfo reference, you should have a pTypeLib->Release() in the destructor and a pTypeLib->AddRef() somewhere in the code that creates the ITypeInfo implementing object.
Well that's C++ stuff. Remember that all this is implemented in pure C. The relevant code searches a linked list for a ITypeInfoImpl struct, which stores all the data and the COM Vtable. It then casts it to an ITypeInfo and incs the refcount:
*ppTInfo = (ITypeInfo*)pTypeInfo; ITypeInfo_AddRef(*ppTInfo);
So, what you actually get out of this method is a pointer to an internal data structure rather than a constructed object....