コード例 #1
0
 internal static extern ErrorCode QueryDisplayConfig(
     [In] QueryDisplayConfigRequest request,
     [In, Out] ref int pathInfoArrayElementCount,
     [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] PathInfo[] pathInfoArray,
     [In, Out] ref int modeInfoArrayElementCount,
     [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] ModeInfo[] modeInfoArray,
     [Out] out TopologyIndicators currentTopologyId
     );
コード例 #2
0
 internal static extern ErrorCode QueryDisplayConfig(
     [In] QueryDisplayConfigRequest request,
     [In, Out] ref int pathInfoArrayElementCount,
     [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] PathInfo[] pathInfoArray,
     [In, Out] ref int modeInfoArrayElementCount,
     [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] ModeInfo[] modeInfoArray,
     [In] IntPtr reserved
     );
コード例 #3
0
        /// <summary>Instantiates a new <see cref="DisplayConfiguration"/>.</summary>
        /// <param name="request">A value of the <see cref="QueryDisplayConfigRequest"/> enumeration; must not be <see cref="QueryDisplayConfigRequest.None"/>.</param>
        /// <exception cref="DisplayConfigException"/>
        private DisplayConfiguration(QueryDisplayConfigRequest request)
        {
            this.request = request;

            try
            {
                this.Refresh();
            }
            catch (Exception ex)
            {
                throw new DisplayConfigException("Failed to instantiate display configuration.", ex);
            }
        }
コード例 #4
0
        public static DisplayConfiguration Query(QueryDisplayConfigRequest request)
        {
            if (request == QueryDisplayConfigRequest.None)
            {
                throw new InvalidEnumArgumentException("request", (int)request, typeof(QueryDisplayConfigRequest));
            }

            // TODO - store the DisplayConfiguration in a Dictionary<QueryDisplayConfigRequest, DisplayConfiguration> ?
            try
            {
                return(new DisplayConfiguration(request));
            }
            catch (DisplayConfigException)
            {
                throw;
            }
        }
コード例 #5
0
        /// <summary>Retrieves information about all possible display paths for all display devices, or views, in the current setting.</summary>
        /// <param name="request">The type of information to retrieve; must not be <see cref="QueryDisplayConfigRequest.None"/>.</param>
        /// <param name="pathInfoArray">Receives an array of <see cref="Paths"/> elements; can't be null.
        /// <para>
        /// Each element in <paramref name="pathInfoArray"/> describes a single path from a source to a target.
        /// The source and target mode information indexes are only valid in combination with the <paramref name="modeInfoArray"/> tables that are returned for the API at the same time.
        /// The <paramref name="pathInfoArray"/> is always returned in path priority order.
        /// </para>
        /// </param>
        /// <param name="modeInfoArray">Receives an array of <see cref="DisplayModes"/> elements; can't be null.</param>
        /// <param name="currentTopologyId">When <paramref name="request"/> is or specifies <see cref="QueryDisplayConfigRequest.DatabaseCurrent"/>, receives the identifier of the currently active topology in the CCD database.</param>
        /// <returns>Returns <see cref="ErrorCode.None"/> on success, otherwise returns one of the following <see cref="ErrorCode"/>:
        /// <see cref="ErrorCode.InvalidParameter"/>,
        /// <see cref="ErrorCode.NotSupported"/>,
        /// <see cref="ErrorCode.AccessDenied"/>,
        /// <see cref="ErrorCode.GenFailure"/> or
        /// <see cref="ErrorCode.InsufficientBuffer"/>.
        /// </returns>
        private static ErrorCode QueryDisplayConfig(QueryDisplayConfigRequest request, out PathInfo[] pathInfoArray, out ModeInfo[] modeInfoArray, out TopologyIndicators currentTopologyId)
        {
            currentTopologyId = TopologyIndicators.Unspecified;

            var errorCode = SafeNativeMethods.GetDisplayConfigBufferSizes(request, out int pathInfoArrayElementCount, out int modeInfoArrayElementCount);

            if (errorCode != ErrorCode.None)
            {
                pathInfoArray = new PathInfo[0];
                modeInfoArray = new ModeInfo[0];
                return(errorCode);
            }

            pathInfoArray = new PathInfo[pathInfoArrayElementCount];
            modeInfoArray = new ModeInfo[modeInfoArrayElementCount];

            if (request.HasFlag(QueryDisplayConfigRequest.DatabaseCurrent))
            {
                return(SafeNativeMethods.QueryDisplayConfig(request, ref pathInfoArrayElementCount, pathInfoArray, ref modeInfoArrayElementCount, modeInfoArray, out currentTopologyId));
            }

            return(SafeNativeMethods.QueryDisplayConfig(request, ref pathInfoArrayElementCount, pathInfoArray, ref modeInfoArrayElementCount, modeInfoArray, IntPtr.Zero));
        }
コード例 #6
0
 internal static extern ErrorCode GetDisplayConfigBufferSizes(
     [In] QueryDisplayConfigRequest request,
     [Out] out int pathArrayElementCount,
     [Out] out int modeInfoArrayElementCount
     );