コード例 #1
0
ファイル: PROPVARIANT..cs プロジェクト: nmoschkin/DataTools5
        private static Array CrackSingleDimSafeArray(IntPtr psa)
        {
            uint cDims = PropVariantNativeMethods.SafeArrayGetDim(psa);

            if (cDims != 1L)
            {
                throw new ArgumentException(LocalizedMessages.PropVariantMultiDimArray, "psa");
            }

            int lBound = PropVariantNativeMethods.SafeArrayGetLBound(psa, 1U);
            int uBound = PropVariantNativeMethods.SafeArrayGetUBound(psa, 1U);
            int n      = uBound - lBound + 1;
            // uBound is inclusive
            var array = new object[n];

            for (int i = lBound, loopTo = uBound; i <= loopTo; i++)
            {
                array[i] = PropVariantNativeMethods.SafeArrayGetElement(psa, ref i);
            }
            return(array);
        }