Пример #1
0
        ///  <summary>
        ///  Retrieves the number of Input reports the host can store.
        ///  </summary>
        ///
        ///  <param name="hidDeviceObject"> a handle to a device  </param>
        ///  <param name="numberOfInputBuffers"> an integer to hold the returned value. </param>
        ///
        ///  <returns>
        ///  True on success, False on failure.
        ///  </returns>
        public Boolean GetNumberOfInputBuffers(SafeFileHandle hidDeviceObject, ref Int32 numberOfInputBuffers)
        {
            Boolean success = false;

            try
            {
                if (!((DeviceManagement.IsWindows98Gold())))
                {
                    //  ***
                    //  调用API函数: HidD_GetNumInputBuffers
                    success = HidDeclarations.HidD_GetNumInputBuffers(hidDeviceObject, ref numberOfInputBuffers);
                    Debug.WriteLine(this.MyDebugging.ResultOfAPICall("HidD_GetNumInputBuffers"));
                }
                else
                {
                    //  Under Windows 98 Gold, the number of buffers is fixed at 2.

                    numberOfInputBuffers = 2;
                    success = true;
                }

                return(success);
            }
            catch (Exception ex)
            {
                DisplayException(MODULE_NAME, ex);
                throw;
            }
        }
Пример #2
0
 ///  <summary>
 ///  sets the number of input reports the host will store.
 ///  Requires Windows XP or later.
 ///  </summary>
 ///
 ///  <param name="hidDeviceObject"> a handle to the device.</param>
 ///  <param name="numberBuffers"> the requested number of input reports.  </param>
 ///
 ///  <returns>
 ///  True on success. False on failure.
 ///  </returns>
 public Boolean SetNumberOfInputBuffers(SafeFileHandle hidDeviceObject, Int32 numberBuffers)
 {
     try
     {
         if (!DeviceManagement.IsWindows98Gold())
         {
             //  ***
             //  调用API函数: HidD_SetNumInputBuffers
             HidDeclarations.HidD_SetNumInputBuffers(hidDeviceObject, numberBuffers);
             Debug.WriteLine(this.MyDebugging.ResultOfAPICall("HidD_SetNumInputBuffers"));
             return(true);
         }
         else
         {
             //  Not supported under Windows 98 Gold.
             return(false);
         }
     }
     catch (Exception ex)
     {
         DisplayException(MODULE_NAME, ex);
         throw;
     }
 }