次の方法で共有


COleSafeArray::GetUBound

セーフ配列の各次元の上限を返します。

void GetUBound(
   DWORD dwDim,
   long* pUBound 
);

パラメーター

  • dwDim
    上限を取得する配列のサイズ。

  • pUBound
    上限を返す場所へのポインター。

解説

エラーの場合、関数は COleException クラス をスローします。

使用例

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

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

//get upper bound for 1st dimension
saMatrix.GetUBound(1, &lUBound);

ASSERT(lUBound == 9);

//get upper bound for 2nd dimension
saMatrix.GetUBound(2, &lUBound);

ASSERT(lUBound == 4);

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

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

//get upper bound for 1st dimension
saVector.GetUBound(1, &lUBound);

ASSERT(lUBound == 5);

必要条件

ヘッダー : afxdisp.h

参照

関連項目

COleSafeArray クラス

階層図

COleSafeArray::GetLBound

SafeArrayGetUBound