コード例 #1
0
        public CcmErrorCode GetConnectionAttributes(int connectionId, out CcmNameValuePair[] attributes)
        {
            var ptrSize = Marshal.SizeOf(typeof(CcmNameValuePair));
            var ptr     = IntPtr.Zero;

            var result = Environment.Is64BitProcess ?
                         CcmSdk64.CCMGetConnectionAttributes(connectionId, out var count, ref ptr) :
                         CcmSdk32.CCMGetConnectionAttributes(connectionId, out count, ref ptr);

            attributes = new CcmNameValuePair[count];
            for (int i = 0; i < count; i++)
            {
                var nPtr = IntPtr.Add(ptr, i * ptrSize);
                attributes[i] = Marshal.PtrToStructure <CcmNameValuePair>(nPtr);
            }

            _ = Environment.Is64BitProcess ?
                CcmSdk64.CCMFreeNameValuePair(count, ptr) :
                CcmSdk32.CCMFreeNameValuePair(count, ptr);

            return((CcmErrorCode)result);
        }