示例#1
0
        public static string GetFullAttributeName(ImaqdxSessionHandle session, string partialName)
        {
            Debug.Assert(session != null, "The session parameter cannot be null.");
            Debug.Assert(!session.IsInvalid, "The session parameter must be a valid handle.");
            Debug.Assert(partialName != null, "The partialName parameter cannot be null.");

            IntPtr stringPtr = IntPtr.Zero;

            try
            {
                int status = NiImaqdxDll.IMAQdxGetFullyQualifiedAttributeName(session, partialName, ref stringPtr);
                if (status == -1074360305)
                {
                    // This error is returned when the attribute is not supported by the camera
                    // In this case we do not want to return an exception
                    // Return an empty string to indicate the the attribute was not found
                    return(string.Empty);
                }

                ExceptionBuilder.CheckErrorAndThrow(status);
                return(Marshal.PtrToStringAnsi(stringPtr));
            }
            finally
            {
                if (stringPtr != IntPtr.Zero)
                {
                    int status = NiImaqdxDll.IMAQdxDispose(stringPtr);
                    ExceptionBuilder.CheckErrorAndThrow(status);
                }
            }
        }