Proper use of variants with VT_RECORD and VT_BYREF

I need some better understanding of records stored in VARIANT.

If there is a VT_RECORD typed variant, it has the following structure (in 32-bit):

V->vt = VT_RECORD
V->DATA1 //(8 byte offset)  memory pointer to record's data (*void)
V->DATA2 //(12 byte offset) pointer to IRecordInfo interface (*IRecordInfo)

It seems when allocating the record, the IRecordInfo object is AddReffed So when destroying the variant, it's necessary to release the IRecordInfo object as well.

But in case of BYREF variant?

In this case the variant is build in this way:

V->vt = VT_RECORD | VT_BYREF
V->DATA1 // -> pointer to a pointer of record's data (**void)
V->DATA2 //-> pointer to IRecordInfo interface (here experienced it is not (**IRecordInfo) but (*IRecordInfo))

What has to be done with the IRecordInfo pointer when allocating or deallocating a BYREF-ed record?

BYREF variants normally don't change any memory when used, they can be freed without dereferencing.

But here now I have a pointer to *IRecordInfo.
What is done by VariantClear, when it is freeing the BYREF variant?
Does it dereference the IRecordInfo object or not?

Experience welcomed!

Upvotes: 0

Views: 163

Answers (0)

Related Questions