HidLibrary.NativeMethods.HidD_SetFeature C# (CSharp) Method

HidD_SetFeature() private method

private HidD_SetFeature ( IntPtr hidDeviceObject, byte lpReportBuffer, int reportBufferLength ) : bool
hidDeviceObject System.IntPtr
lpReportBuffer byte
reportBufferLength int
return bool
        internal static extern bool HidD_SetFeature(IntPtr hidDeviceObject, byte[] lpReportBuffer, int reportBufferLength);

Same methods

NativeMethods::HidD_SetFeature ( SafeFileHandle hidDeviceObject, byte lpReportBuffer, int reportBufferLength ) : bool

Usage Example

Example #1
0
        public bool WriteFeatureData(byte[] data)
        {
            if (_deviceCapabilities.FeatureReportByteLength <= 0)
            {
                return(false);
            }

            var buffer = CreateFeatureOutputBuffer();

            Array.Copy(data, 0, buffer, 0, Math.Min(data.Length, _deviceCapabilities.FeatureReportByteLength));


            IntPtr hidHandle = IntPtr.Zero;
            bool   success   = false;

            try
            {
                hidHandle = OpenDeviceIO(_devicePath, NativeMethods.ACCESS_NONE);

                var overlapped = new NativeOverlapped();
                success = NativeMethods.HidD_SetFeature(hidHandle, buffer, buffer.Length);
            }
            catch (Exception exception)
            {
                throw new Exception(string.Format("Error accessing HID device '{0}'.", _devicePath), exception);
            }
            finally
            {
                if (hidHandle != IntPtr.Zero)
                {
                    CloseDeviceIO(hidHandle);
                }
            }
            return(success);
        }
All Usage Examples Of HidLibrary.NativeMethods::HidD_SetFeature