Пример #1
0
        public static string WriteAttributesToString(ImaqdxSessionHandle session)
        {
            Debug.Assert(session != null, "The session parameter cannot be null.");
            Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle.");

            IntPtr stringPtr = IntPtr.Zero;

            try
            {
                int status = NiImaqdxDll.IMAQdxWriteAttributesToString(session, ref stringPtr);
                ExceptionBuilder.CheckErrorAndThrow(status);
                string attributesString = Marshal.PtrToStringAnsi(stringPtr);
                return(attributesString == null ? string.Empty : attributesString);
            }
            finally
            {
                if (stringPtr != IntPtr.Zero)
                {
                    int status = NiImaqdxDll.IMAQdxDispose(stringPtr);
                    ExceptionBuilder.CheckErrorAndThrow(status);
                }
            }
        }