COleSafeArray::Create

void Create( VARTYPE vtSrc, DWORD dwDims, DWORD* rgElements );

void Create( VARTYPE vtSrc, DWORD dwDims, SAFEARRAYBOUND* rgsabounds );

Parameters

vtSrc

The base type of the array (that is, the VARTYPE of each element of the array). The VARTYPE is restricted to a subset of the variant types. Neither the VT_ARRAY nor the VT_BYREF flag can be set. VT_EMPTY and VT_NULL are not valid base types for the array. All other types are legal.

dwDims

Number of dimensions in the array. This can be changed after the array is created with Redim.

rgElements

Pointer to an array of the number of elements for each dimension in the array.

rgsabounds

Pointer to a vector of bounds (one for each dimension) to allocate for the array.

Remarks

Call this function to allocate and initialize the data for the array. This function will clear the current array data if necessary. On error, the function throws a CMemoryException.

Example

COleSafeArray saMatrix;
DWORD numElements[] = {10, 5};

// creates a 2 dimensional safearray of type VT_I2 
// with size 10x5 elements, with all indices starting at 0(default)
saMatrix.Create(VT_I2, 2, numElements);

ASSERT(saMatrix.GetDim() == 2);

COleSafeArray saVector;
SAFEARRAYBOUND rgsabounds[] = { {5, 2} };

// creates a 1 dimensional safearray of type VT_I1 
// with size 5 elements, with the index starting at 2
saVector.Create(VT_I1, 1, rgsabounds);

ASSERT(saVector.GetDim() == 1);

COleSafeArray OverviewClass MembersHierarchy Chart

See Also   SafeArrayCreate