public static extern bool SetupDiGetDeviceRegistryProperty(
     IntPtr deviceInfoSet,
     DeviceInfoData deviceInfoData,
     Spdrp property,
     IntPtr propertyRegDataType,
     IntPtr propertyBuffer,
     uint propertyBufferSize,
     out uint requiredSize);
Пример #2
0
 public static extern bool SetupDiGetDeviceRegistryProperty(
     IntPtr deviceInfoSet,
     DeviceInfoData deviceInfoData,
     Spdrp property,
     out RegistryType propertyRegDataType,
     byte[] propertyBuffer,
     uint propertyBufferSize,
     out uint requiredSize);
Пример #3
0
        /// <summary>
        /// The setup di get device interface detail.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        /// <exception cref="Win32Exception">
        /// Is thrown when the unsafe method calls fails.
        /// </exception>
        /// <summary>
        /// The get property.
        /// </summary>
        /// <param name="deviceInfoSet">
        /// The device info set.
        /// </param>
        /// <param name="deviceInfoData">
        /// The device info data.
        /// </param>
        /// <param name="spdrpDeviceDescription">
        /// The spdrp Device Description.
        /// </param>
        /// <returns>
        /// The <see cref="BaseDeviceProperty"/>.
        /// </returns>
        public BaseDeviceProperty GetProperty(IntPtr deviceInfoSet, DeviceInfoData deviceInfoData, Spdrp spdrpDeviceDescription)
        {
            uint requiredSize;
            var  success   = UnsafeNativeMethods.SetupDiGetDeviceRegistryProperty(deviceInfoSet, deviceInfoData, spdrpDeviceDescription, IntPtr.Zero, IntPtr.Zero, 0, out requiredSize);
            var  lastError = _marshalWrapper.GetLastWin32Error();

            if (!success && lastError.IsInsufficientBuffer)
            {
                var buffer = new byte[requiredSize];

                RegistryType regType;
                success = UnsafeNativeMethods.SetupDiGetDeviceRegistryProperty(deviceInfoSet, deviceInfoData, spdrpDeviceDescription, out regType, buffer, (uint)buffer.Length, out requiredSize);
                if (success)
                {
                    return(_devicePropertyFactory.Create(regType, buffer));
                }
            }

            return(_devicePropertyFactory.Create(RegistryType.Unknown, null));
        }
        /// <summary>
        /// The setup di get device interface detail.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        /// <exception cref="Win32Exception">
        /// Is thrown when the unsafe method calls fails.
        /// </exception>
        /// <summary>
        /// The get property.
        /// </summary>
        /// <param name="deviceInfoSet">
        /// The device info set.
        /// </param>
        /// <param name="deviceInfoData">
        /// The device info data.
        /// </param>
        /// <param name="spdrpDeviceDescription">
        /// The spdrp Device Description.
        /// </param>
        /// <returns>
        /// The <see cref="BaseDeviceProperty"/>.
        /// </returns>
        public BaseDeviceProperty GetProperty(IntPtr deviceInfoSet, DeviceInfoData deviceInfoData, Spdrp spdrpDeviceDescription)
        {
            uint requiredSize;
            var success = UnsafeNativeMethods.SetupDiGetDeviceRegistryProperty(deviceInfoSet, deviceInfoData, spdrpDeviceDescription, IntPtr.Zero, IntPtr.Zero, 0, out requiredSize);
            var lastError = _marshalWrapper.GetLastWin32Error();
            if (!success && lastError.IsInsufficientBuffer)
            {
                var buffer = new byte[requiredSize];

                RegistryType regType;
                success = UnsafeNativeMethods.SetupDiGetDeviceRegistryProperty(deviceInfoSet, deviceInfoData, spdrpDeviceDescription, out regType, buffer, (uint)buffer.Length, out requiredSize);
                if (success)
                {
                    return _devicePropertyFactory.Create(regType, buffer);
                }
            }

            return _devicePropertyFactory.Create(RegistryType.Unknown, null);
        }