/// <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 = 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; } }
/// <summary> /// Requests to stop receiving notification messages when a device in an /// interface class is attached or removed. /// </summary> /// <param name="deviceNotificationHandle"> handle returned previously by /// RegisterDeviceNotification. </param> public void StopReceivingDeviceNotifications(IntPtr deviceNotificationHandle) { try { // 调用API函数 DeviceManagement.UnregisterDeviceNotification(deviceNotificationHandle); Debug.WriteLine("在函数StopReceivingDeviceNotifications中" + this.MyDebugging.ResultOfAPICall("UnregisterDeviceNotification")); } catch (Exception) { throw; } }
/// <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 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; } }