コード例 #1
0
        /// <summary>Returns the device path of an adapter given its target info.</summary>
        /// <param name="targetInfo">A valid <see cref="PathTargetInfo"/> structure.</param>
        /// <returns>Returns the adapter device path.</returns>
        /// <exception cref="ArgumentException"/>
        /// <exception cref="DisplayConfigException"/>
        public static string GetAdapterDevicePath(PathTargetInfo targetInfo)
        {
            if (targetInfo == PathTargetInfo.Empty)
            {
                throw new ArgumentException("Invalid target info.", "targetInfo");
            }

            return(GetAdapterDevicePath(targetInfo.Identifier));
        }
コード例 #2
0
        /// <summary>Returns a <see cref="TargetDeviceDescription"/> structure containing information about the specified display target.</summary>
        /// <param name="targetInfo">A valid <see cref="PathTargetInfo"/> structure; must not be empty.</param>
        /// <returns>Returns a <see cref="TargetDeviceDescription"/> structure containing information about the specified display target.</returns>
        /// <exception cref="ArgumentException"/>
        /// <exception cref="DisplayConfigException"/>
        public static TargetDeviceDescription GetTargetDeviceDescription(PathTargetInfo targetInfo)
        {
            if (targetInfo == PathTargetInfo.Empty)
            {
                throw new ArgumentException("Invalid target info: empty.", "targetInfo");
            }

            var deviceName = new TargetDeviceDescription(targetInfo.Identifier);
            var errorCode  = SafeNativeMethods.DisplayConfigGetDeviceInfo(deviceName);

            if (errorCode == ErrorCode.None)
            {
                return(deviceName);
            }

            throw GetException(errorCode);
        }