Help Center

DSAFEARRAY.Putmethod

Stores the data element at a given location in the array.

COMmethodDSafeArray.incdocumented

Syntax

FUNCTION Put (BYVAL prgIndices AS LONG PTR, BYVAL pData AS ANY PTR) AS HRESULT
FUNCTION Put (BYVAL idx AS LONG, BYVAL pData AS ANY PTR) AS HRESULT
FUNCTION Put (BYVAL cElem AS LONG, BYVAL cDim AS LONG, BYVAL pData AS ANY PTR) AS HRESULT

Parameters

NameDescription
prgIndicesPointer to a vector of indexes for each dimension of the array. The right-most (least significant) dimension is rgIndices(0). The left-most dimension is stored at prgIndices(@psa.cDims – 1).
pDataPointer to the data to assign to the array. The variant types VT_DISPATCH, VT_UNKNOWN, and VT_BSTR are pointers, and do not require another level of indirection.
bsDataA BSTRING.
bsDataA DVARIANT.
idxIndex of the element of the array.
pDataPointer to the data to assign to the array. The variant types VT_DISPATCH, VT_UNKNOWN, and VT_BSTR are pointers, and do not require another level of indirection.
bsDataA BSTRING.
bsDataA DVARIANT.
idxIndex of the element.
cElemIndex of the element of the array.
cDimDimension number of the array.
pDataPointer to the data to assign to the array. The variant types VT_DISPATCH, VT_UNKNOWN, and VT_BSTR are pointers, and do not require another level of indirection.
bsDataA BSTRING.
bsDataA DVARIANT.

Return value

S_OK (0) on success or an HRESULT code on failure.

Description

Stores the data element at a given location in the array.

Multidimensional array:

One-dimensional array:

Two-dimensional array:

Remarks

This function automatically calls SAfeArrayLock and SafeArrayUnlock before and after assigning the element. If the data element is a string, object, or variant, the function copies it correctly when the safe array is destroyed. If the existing element is a string, object, or variant, it is cleared correctly. If the data element is a VT_DISPATCH or VT_UNKNOWN, AddRef is called to increment the object's reference count.

Multiple locks can be on an array. Elements can be put into an array while the array is locked by other operations.

Reference

  • Include file DSafeArray.inc
  • Defined in AfxNova/DSafeArray.inc:1443
  • Documented in COM/DSAFEARRAY Class.md
  • Topic: DSAFEARRAY Class