public CcmErrorCode EnumerateConnections(out int[] connectionIds) { var ptrSize = Marshal.SizeOf(typeof(int)); var ptr = IntPtr.Zero; var result = Environment.Is64BitProcess ? CcmSdk64.CCMEnumerateConnections(out var count, ref ptr) : CcmSdk32.CCMEnumerateConnections(out count, ref ptr); connectionIds = new int[count]; for (int i = 0; i < count; i++) { var nPtr = IntPtr.Add(ptr, i * ptrSize); connectionIds[i] = Marshal.ReadInt32(nPtr); } if (Environment.Is64BitProcess) { CcmSdk64.CCMFreeMemory(ptr); } else { CcmSdk32.CCMFreeMemory(ptr); } return((CcmErrorCode)result); }