views:

17

answers:

1

The CComSafeArray::SetAt method provides a parameter to control whether the referenced variable is copied:

HRESULT SetAt(
LONG lIndex,
const T& t,
BOOL bCopy = TRUE
);

... but the CComSafeArray::MultiDimSetAt method does not offer the same parameter:

HRESULT MultiDimSetAt(
const LONG * alIndex,
const T& t 
);

Two questions:

1.) Is there a reason that this option is not offered in the MultiDim method?

2.) The docs don't specify if the referenced variable is copied. Is it copied implicitly?

(In my case I would like it not to be copied, since it is a temporary wrapper for a VARIANT type that could be 'Detach'd after setting it into the array)

A: 

Internally MultiDimSetAt uses SafeArrayPutElement function. It means that BSTRs would be copied and objects would be AddRef'ed.

Andrey