예제 #1
0
        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);
        }
예제 #2
0
        public CcmErrorCode GetErrorMessageStringForCode(int sessionId, uint errorCode, out string errorMessage)
        {
            var ptr = IntPtr.Zero;

            var result = Environment.Is64BitProcess ?
                         CcmSdk64.CCMGetErrorMessageStringForCode(sessionId, errorCode, ref ptr) :
                         CcmSdk32.CCMGetErrorMessageStringForCode(sessionId, errorCode, ref ptr);

            errorMessage = Marshal.PtrToStringUTF8(ptr);

            if (Environment.Is64BitProcess)
            {
                CcmSdk64.CCMFreeMemory(ptr);
            }
            else
            {
                CcmSdk32.CCMFreeMemory(ptr);
            }

            return((CcmErrorCode)result);
        }