Esempio n. 1
0
        /// <summary>Returns the device path of an adapter given its source info.</summary>
        /// <param name="sourceInfo">A valid <see cref="PathSourceInfo"/> structure.</param>
        /// <returns>Returns the adapter device path.</returns>
        /// <exception cref="ArgumentException"/>
        /// <exception cref="DisplayConfigException"/>
        public static string GetAdapterDevicePath(PathSourceInfo sourceInfo)
        {
            if (sourceInfo == PathSourceInfo.Empty)
            {
                throw new ArgumentException("Invalid source info.", "sourceInfo");
            }

            return(GetAdapterDevicePath(sourceInfo.Identifier));
        }
Esempio n. 2
0
        public static string GetSourceGDIDeviceName(PathSourceInfo sourceInfo)
        {
            if (sourceInfo == PathSourceInfo.Empty)
            {
                throw new ArgumentException("Invalid source info: empty.", "sourceInfo");
            }

            var deviceName = new SourceDeviceName(sourceInfo.Identifier);
            var errorCode  = SafeNativeMethods.DisplayConfigGetDeviceInfo(deviceName);

            if (errorCode == ErrorCode.None)
            {
                return(deviceName.GDIDeviceName.TrimEnd('\0'));
            }

            throw GetException(errorCode);
        }