コード例 #1
0
 public static extern bool SetupDiGetDeviceInterfaceDetail(
     IntPtr deviceInfoSet,
     DeviceInterfaceData deviceInterfaceData,
     IntPtr deviceInterfaceDetailData,
     int deviceInterfaceDetailDataSize,
     ref int requiredSize,
     DeviceInfoData deviceInfoData);
コード例 #2
0
 public static extern bool SetupDiGetDeviceInterfaceDetail(
     IntPtr deviceInfoSet,
     DeviceInterfaceData deviceInterfaceData,
     IntPtr deviceInterfaceDetailData,
     int deviceInterfaceDetailDataSize,
     ref int requiredSize,
     DeviceInfoData deviceInfoData);
コード例 #3
0
        /// <summary>
        /// The get device interface detail.
        /// </summary>
        /// <param name="deviceInformationSetHandle">
        /// The device information set handle.
        /// </param>
        /// <param name="deviceInterfaceData">
        /// The device interface data.
        /// </param>
        /// <returns>
        /// The <see cref="DeviceInterfaceDetail"/>.
        /// </returns>
        public IDeviceInterfaceDetail GetDeviceInterfaceDetail(IntPtr deviceInformationSetHandle, DeviceInterfaceData deviceInterfaceData)
        {
            var bufferSize = 0;
            var success    = UnsafeNativeMethods.SetupDiGetDeviceInterfaceDetail(deviceInformationSetHandle, deviceInterfaceData, IntPtr.Zero, 0, ref bufferSize, IntPtr.Zero);
            var lastError  = _marshalWrapper.GetLastWin32Error();

            if (!success && lastError.IsInsufficientBuffer)
            {
                // TODO: Somehow we need to get rid of setting up properties of the deviceInterfacedetails and use them either direct and pass them into the constructor or think of another way.
                var deviceInterfaceDetails = _deviceInterfaceDetailFactory.Create(deviceInformationSetHandle, bufferSize);
                success = UnsafeNativeMethods.SetupDiGetDeviceInterfaceDetail(
                    deviceInformationSetHandle,
                    deviceInterfaceData,
                    deviceInterfaceDetails.DeviceInterfaceDetailBuffer,
                    bufferSize,
                    ref bufferSize,
                    deviceInterfaceDetails.DeviceInfoData);

                return(!success?_deviceInterfaceDetailFactory.CreateNull() : (IDeviceInterfaceDetail)deviceInterfaceDetails);
            }

            return(_deviceInterfaceDetailFactory.CreateNull());
        }
コード例 #4
0
        /// <summary>
        /// The get device interface detail.
        /// </summary>
        /// <param name="deviceInformationSetHandle">
        /// The device information set handle.
        /// </param>
        /// <param name="deviceInterfaceData">
        /// The device interface data.
        /// </param>
        /// <returns>
        /// The <see cref="DeviceInterfaceDetail"/>.
        /// </returns>
        public IDeviceInterfaceDetail GetDeviceInterfaceDetail(IntPtr deviceInformationSetHandle, DeviceInterfaceData deviceInterfaceData)
        {
            var bufferSize = 0;
            var success = UnsafeNativeMethods.SetupDiGetDeviceInterfaceDetail(deviceInformationSetHandle, deviceInterfaceData, IntPtr.Zero, 0, ref bufferSize, IntPtr.Zero);
            var lastError = _marshalWrapper.GetLastWin32Error();

            if (!success && lastError.IsInsufficientBuffer)
            {
                // TODO: Somehow we need to get rid of setting up properties of the deviceInterfacedetails and use them either direct and pass them into the constructor or think of another way.
                var deviceInterfaceDetails = _deviceInterfaceDetailFactory.Create(deviceInformationSetHandle, bufferSize);
                success = UnsafeNativeMethods.SetupDiGetDeviceInterfaceDetail(
                    deviceInformationSetHandle,
                    deviceInterfaceData,
                    deviceInterfaceDetails.DeviceInterfaceDetailBuffer,
                    bufferSize,
                    ref bufferSize,
                    deviceInterfaceDetails.DeviceInfoData);

                return !success ? _deviceInterfaceDetailFactory.CreateNull() : (IDeviceInterfaceDetail)deviceInterfaceDetails;
            }

            return _deviceInterfaceDetailFactory.CreateNull();
        }
コード例 #5
0
 public static extern bool SetupDiEnumDeviceInterfaces(
     IntPtr deviceInfoSet, 
     DeviceInfoData deviceInfoData, 
     ref Guid interfaceClassGuid, 
     uint memberIndex, 
     DeviceInterfaceData deviceInterfaceData);
コード例 #6
0
 public static extern bool SetupDiEnumDeviceInterfaces(
     IntPtr deviceInfoSet,
     DeviceInfoData deviceInfoData,
     ref Guid interfaceClassGuid,
     uint memberIndex,
     DeviceInterfaceData deviceInterfaceData);