COleSafeArray::Create

分配和初始化数据为该数组。

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

参数

  • vtSrc
    数组(即 VARTYPE 的基础数组的每个元素)。 VARTYPE 限制不同类型的子集。 VT_ARRAYVT_BYREF 标志不可设置。 VT_EMPTYVT_NULL 是数组的无效的基类型。 其他类型是非法的。

  • dwDims
    维度的数字数组中。 这,数组。Redim后,创建可更改。

  • rgElements
    对于元素数的指针每个维度的数组中。

  • rgsabounds
    为每个维度的)分配的矢量的指针区域(一个用于数组。

备注

此功能如果需要,将清除当前数组数据。 在错误,该函数引发 CMemoryException

示例

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);

要求

Header: afxdisp.h

请参见

参考

COleSafeArray Class

层次结构图

其他资源

SafeArrayCreate